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

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