annotate parsedb.sh @ 0:183edf446dcf draft default tip

Uploaded
author davidvanzessen
date Mon, 17 Jul 2017 07:44:27 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
1 #!/bin/bash
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
2 dir="$(cd "$(dirname "$0")" && pwd)"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
3
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
4 action=$1
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
5 input=$2
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
6 output=$3
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
7
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
8 cp $input $PWD/input.tab
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
9
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
10 input="$PWD/input.tab"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
11
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
12 mkdir $PWD/outdir
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
13
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
14 if [ "fasta" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
15 python3 $dir/ParseDb.py fasta -d $input --outdir $PWD/outdir --outname output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
16 mv $PWD/outdir/output_sequences.fasta $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
17 elif [ "clip" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
18 python3 $dir/ParseDb.py clip -d $input --outdir $PWD/outdir --outname output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
19 mv $PWD/outdir/output_sequences.fasta $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
20 elif [ "split" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
21 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
22 label=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
23 mkdir $PWD/split
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
24 python3 $dir/ParseDb.py split -d $input --outdir $PWD/split --outname output -f $field
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
25 #rename "s/output_${field}/$label/" $PWD/split/*
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
26 elif [ "add" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
27 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
28 value=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
29 python3 $dir/ParseDb.py add -d $input --outdir $PWD/outdir --outname output -f $field -u $value
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
30 mv $PWD/outdir/output_parse-add.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
31 elif [ "delete" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
32 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
33 value=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
34 regex=$6
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
35 if [ "true" == "$regex" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
36 regex="--regex"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
37 else
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
38 regex=""
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
39 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
40 python3 $dir/ParseDb.py delete -d $input --outdir $PWD/outdir --outname output -f $field -u $value --logic any $regex
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
41 mv $PWD/outdir/output_parse-delete.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
42 elif [ "drop" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
43 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
44 python3 $dir/ParseDb.py drop -d $input --outdir $PWD/outdir --outname output -f $field
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
45 mv $PWD/outdir/output_parse-drop.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
46 elif [ "index" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
47 field=$4
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
48 python3 $dir/ParseDb.py index -d $input --outdir $PWD/outdir --outname output -f $field
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
49 mv $PWD/outdir/output_parse-index.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
50 elif [ "rename" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
51 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
52 newname=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
53 python3 $dir/ParseDb.py rename -d $input --outdir $PWD/outdir --outname output -f $field -k $newname
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
54 mv $PWD/outdir/output_parse-rename.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
55 elif [ "select" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
56 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
57 value=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
58 regex=$6
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
59 if [ "true" == "$regex" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
60 regex="--regex"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
61 else
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
62 regex=""
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
63 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
64 python3 $dir/ParseDb.py select -d $input --outdir $PWD/outdir --outname output -f $field -u $value --logic any $regex
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
65 mv $PWD/outdir/output_parse-select.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
66 elif [ "sort" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
67 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
68 num=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
69 tmp=""
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
70 if [ "true" == "$num" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
71 tmp="--num"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
72 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
73 desc=$6
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
74 if [ "true" == "$desc" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
75 tmp="--descend $tmp"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
76 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
77 python3 $dir/ParseDb.py sort -d $input --outdir $PWD/outdir --outname output -f $field $tmp
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
78 mv $PWD/outdir/output_parse-sort.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
79 elif [ "update" == "$action" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
80 field="`cat $input 2> /dev/null | head -n 1 | cut -f$4 | tr '\n\r' ' '`"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
81 value=$5
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
82 replace=$6
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
83 regex=$7
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
84 if [ "true" == "$regex" ] ; then
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
85 regex="--regex"
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
86 else
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
87 regex=""
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
88 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
89 python3 $dir/ParseDb.py update -d $input --outdir $PWD/outdir --outname output -f $field -u $value -t $replace $regex
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
90 mv $PWD/outdir/output_parse-update.tab $output
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
91 fi
183edf446dcf Uploaded
davidvanzessen
parents:
diff changeset
92