Debian Codegraph @

tools/process/concat.sh

raw
1 # ! /bin/bash
2 # Script for Biomaj PostProcess
3 #
4 # concat files
5 #
6 # ARGS :
7 # 1) regular expression for file to apply concat
8 # 2) regular expression for exclude files in result
9 # 3) relativ path name (result of concat)
10 # 4) format (fasta) [OPTIONAL]
11 # 5) types (type1,type2,...) [OPTIONAL]
12 # 6) tags (key:value,key:value,...) [OPTIONAL]
13 #
14 #
15 #
16 # Default input from STDIN unless files specified. To explictly specify STDIN
17 # to be used for input use '-' as filename
18
19
20 if (test $# -lt 3) then
21 echo "arguments:" 1>&2;
22 echo "1: regular expression for include a set of file to apply concat" 1
23 >&2;
24 echo "2: regular expression for exclude a set of file to apply concat" 1
25 >&2;
26 echo "3: result file name (relative path from future_release and name)"
27 1>&2;
28 exit -1;
29
30 fi
31
32 workdir=$datadir/$dirversion/$localrelease/
33 echo "apply concat with set $workdir/$1 to $workdir/$3";
34
35 #Creation des repertoires
36
37 dirtocreate=`dirname $workdir/$3`;
38
39 if (! test -e $dirtocreate ) then
40 echo "mkdir :"$dirtocreate;
41 mkdir -p $dirtocreate
42 fi
43
44 if ( test $? -ne 0 ) then
45 echo "Cannot create $dirtocreate." 1>&2 ;
46 exit 1;
47 fi
48
49
50 cd $workdir;
51
52 echo ;
53
54 files='';
55
56 echo "set a list of file...";
57
58 for expr in $1
59 do
60 # echo "$expr";
61 # dir=`dirname $expr`;
62 # fileExp=`basename $expr`;
63 if [ "$2" != "" ]
64 then
65 files="$files ""`echo $expr | egrep -v $2`";
66 else
67 files="$files $expr";
68 fi
69 done
70
71 echo "";
72 echo "--------------------------";
73 echo "Comput [$workdir/$3]....";
74 echo "change directory:$workdir";
75 echo "$files > $workdir/$3";
76 rm -f $workdir/$3 2> /dev/null ;
77
78 if ( test -z "$files" )
79 then
80 echo "Cannot create $workdir/$3 : no files !" 1>&2 ;
81 exit 1;
82 fi
83
84 echo "cat $files > $workdir/$3";
85
86 for fileToConcat in $files
87 do
88 cat $fileToConcat >> $workdir/$3 ;
89
90 if ( test $? -ne 0 ) then
91 echo "Cannot create $3.[error:$?]" 1>&2 ;
92 exit 1;
93 fi
94 done
95
96 format=""
97 types=""
98 tags=""
99 if [ "$4" != "" ]
100 then
101 format=$4
102 fi
103 if [ "$5" != "" ]
104 then
105 types=$5
106 fi
107 if [ "$6" != "" ]
108 then
109 tags=$6
110 fi
111
112
113
114 echo "##BIOMAJ#$format#$types#$tags#$3"