Mercurial > repos > bitlab > bitlab
comparison gecko/bin/workflow.sh @ 1:35af401890c0 draft
Uploaded
author | bitlab |
---|---|
date | Thu, 13 Dec 2018 07:59:25 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:ee6b15b409e5 | 1:35af401890c0 |
---|---|
1 #!/bin/bash | |
2 | |
3 FL=1000 # frequency limit | |
4 | |
5 if [ $# != 8 ]; then | |
6 echo " ==== ERROR ... you called this script inappropriately." | |
7 echo "" | |
8 echo " usage: $0 seqXName seqYName lenght similarity WL fixedL output.frags output.csv" | |
9 echo "" | |
10 exit -1 | |
11 fi | |
12 | |
13 #{ | |
14 | |
15 | |
16 MYRAND=$((( RANDOM % 10000000) +1)) | |
17 MGDIR=${PWD}/${MYRAND} | |
18 echo "MGDIR $MGDIR" | |
19 mkdir -p ${MGDIR} | |
20 | |
21 genoXname=$(basename "$1") | |
22 genoYname=$(basename "$2") | |
23 genoXname="${genoXname%.*}" | |
24 genoYname="${genoYname%.*}" | |
25 | |
26 | |
27 cp $1 $MGDIR/${genoXname}.fasta | |
28 cp $2 $MGDIR/${genoYname}.fasta | |
29 mkdir -p ${MGDIR}/dictionaries | |
30 mkdir -p ${MGDIR}/fragments | |
31 | |
32 genoXExt="fasta" | |
33 genoYExt="fasta" | |
34 | |
35 | |
36 | |
37 BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
38 | |
39 length=${3} | |
40 similarity=${4} | |
41 WL=${5} # wordSize | |
42 fixedL=${6} | |
43 output=${7} | |
44 csv=${8} | |
45 | |
46 mkdir ${MGDIR}/intermediateFiles | |
47 | |
48 mkdir ${MGDIR}/intermediateFiles/${genoXname}-${genoYname} | |
49 mkdir ${MGDIR}/results | |
50 mkdir ${MGDIR}/intermediateFiles/dictionaries | |
51 mkdir ${MGDIR}/intermediateFiles/hits | |
52 | |
53 # Copiamos los fastas | |
54 ln -s ${MGDIR}/${genoXname}.${genoXname} ${MGDIR}/intermediateFiles/${genoXname}-${genoYname} | |
55 ln -s ${MGDIR}/${genoYname}.${genoYname} ${MGDIR}/intermediateFiles/${genoYname}-${genoXname} | |
56 | |
57 cd ${MGDIR}/intermediateFiles/${genoXname}-${genoYname} | |
58 | |
59 ############### | |
60 | |
61 | |
62 | |
63 echo "${BINDIR}/reverseComplement ${MGDIR}/${genoYname}.${genoXExt} ${genoYname}-revercomp.${genoYExt}" | |
64 ${BINDIR}/reverseComplement ${MGDIR}/${genoYname}.${genoYExt} ${MGDIR}/${genoYname}-revercomp.${genoYExt} | |
65 | |
66 if [[ ! -f ../dictionaries/${genoXname}.d2hP ]]; then | |
67 echo "${BINDIR}/dictionary.sh ${MGDIR}/${genoXname}.${genoXExt} &" | |
68 ${BINDIR}/dictionary.sh ${MGDIR}/${genoXname}.${genoXExt} & | |
69 fi | |
70 | |
71 if [[ ! -f ../dictionaries/${seqYName}.d2hP ]]; then | |
72 echo "${BINDIR}/dictionary.sh ${MGDIR}/${genoYname}.${genoYExt} &" | |
73 ${BINDIR}/dictionary.sh ${MGDIR}/${genoYname}.${genoYExt} & | |
74 fi | |
75 | |
76 if [[ ! -f ../dictionaries/${genoYname}-revercomp.d2hP ]]; then | |
77 echo "${BINDIR}/dictionary.sh ${MGDIR}/${genoYname}-revercomp.${genoYExt} &" | |
78 ${BINDIR}/dictionary.sh ${MGDIR}/${genoYname}-revercomp.${genoYExt} & | |
79 fi | |
80 | |
81 echo "Waiting for the calculation of the dictionaries" | |
82 | |
83 for job in `jobs -p` | |
84 do | |
85 #echo $job | |
86 wait $job | |
87 done | |
88 | |
89 | |
90 | |
91 mv ${genoXname}.d2hP ../dictionaries/ | |
92 mv ${genoXname}.d2hW ../dictionaries/ | |
93 mv ${genoYname}.d2hP ../dictionaries/ | |
94 mv ${genoYname}.d2hW ../dictionaries/ | |
95 mv ${genoYname}-revercomp.d2hP ../dictionaries/ | |
96 mv ${genoYname}-revercomp.d2hW ../dictionaries/ | |
97 | |
98 | |
99 | |
100 # Hacemos enlace simbolico | |
101 ln -s ../dictionaries/${genoXname}.d2hP . | |
102 ln -s ../dictionaries/${genoXname}.d2hW . | |
103 | |
104 ln -s ../dictionaries/${genoYname}.d2hP . | |
105 ln -s ../dictionaries/${genoYname}.d2hW . | |
106 | |
107 ln -s ../dictionaries/${genoYname}-revercomp.d2hP . | |
108 ln -s ../dictionaries/${genoYname}-revercomp.d2hW . | |
109 | |
110 echo "${BINDIR}/comparison.sh ${MGDIR}/${genoXname}.${genoXExt} ${MGDIR}/${genoYname}.${genoYExt} ${length} ${similarity} ${WL} ${fixedL} f &" | |
111 ${BINDIR}/comparison.sh ${MGDIR}/${genoXname}.${genoXExt} ${MGDIR}/${genoYname}.${genoYExt} ${length} ${similarity} ${WL} ${fixedL} f & | |
112 | |
113 echo "${BINDIR}/comparison.sh ${MGDIR}/${genoXname}.${genoXExt} ${MGDIR}/${genoYname}-revercomp.${genoYExt} ${length} ${similarity} ${WL} ${fixedL} r &" | |
114 ${BINDIR}/comparison.sh ${MGDIR}/${genoXname}.${genoXExt} ${MGDIR}/${genoYname}-revercomp.${genoYExt} ${length} ${similarity} ${WL} ${fixedL} r & | |
115 | |
116 echo "Waiting for the comparisons" | |
117 | |
118 for job in `jobs -p` | |
119 do | |
120 #echo $job | |
121 wait $job | |
122 done | |
123 | |
124 | |
125 #echo "rm ${seqYName}-revercomp.${extensionY}" | |
126 #rm ${seqYName}-revercomp.${extensionY} | |
127 | |
128 | |
129 echo "${BINDIR}/combineFrags ${genoXname}-${genoYname}-sf.frags ${genoXname}-${genoYname}-revercomp-sr.frags ${genoXname}-${genoYname}.frags" | |
130 ${BINDIR}/combineFrags ${genoXname}-${genoYname}-sf.frags ${genoXname}-${genoYname}-revercomp-sr.frags ${genoXname}-${genoYname}.frags | |
131 | |
132 #Borramos todo menos los frags y los diccionarios | |
133 | |
134 # Get Info from frags | |
135 echo "${BINDIR}/getInfo ${genoXname}-${genoYname}.frags > ${genoXname}-${genoYname}.csv" | |
136 ${BINDIR}/getInfo ${genoXname}-${genoYname}.frags > ${genoXname}-${genoYname}.csv.tmp | |
137 cat ${genoXname}-${genoYname}.frags.INF ${genoXname}-${genoYname}.csv.tmp > ${genoXname}-${genoYname}.csv | |
138 rm -rf ${genoXname}-${genoYname}.csv.tmp | |
139 | |
140 if [[ -L "../../${genoXname}.fasta" ]] | |
141 then | |
142 rm ../../${genoYname}.fasta | |
143 fi | |
144 | |
145 if [[ -L "../../${genoXname}.fasta" ]] | |
146 then | |
147 rm ../../${genoYname}.fasta | |
148 fi | |
149 | |
150 #Movemos los frags y los info | |
151 mv ${genoXname}-${genoYname}.frags $output | |
152 mv ${genoXname}-${genoYname}.csv $csv | |
153 | |
154 | |
155 | |
156 #echo "Borrando ${seqXName}-${seqYName}" | |
157 cd .. | |
158 | |
159 #rm -rf ${seqXName}-${seqYName} | |
160 | |
161 cd .. | |
162 | |
163 | |
164 rm -r ${MGDIR} | |
165 |