Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

Commit

Permalink
more time efficient computation of contig-correspondance between asse…
Browse files Browse the repository at this point in the history
…mblies
  • Loading branch information
cmdoret committed Aug 6, 2018
1 parent 81011f8 commit e20f8c0
Showing 1 changed file with 8 additions and 35 deletions.
43 changes: 8 additions & 35 deletions src/convert_coord/corresp_contigs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,49 +57,22 @@ eval "$run_fun" <<CORR
#BSUB -n 36
#BSUB -R "span[ptile=36]"
MAX_PROC=32
master_pid=\$\$
echo "\$master_pid"
# Used to display loading bar
source src/misc/jobs_manager.sh
# Total contigs to process
tot=\$(grep ">" $OLD_REF | wc -l )
# Get start position of all contigs in the ordered assembly and whether
# They have been reversed and/or complemented. Store infos in a file.
declare -i n=0
grep ">" $OLD_REF | while read tig
do
((n++))
# Loading bar animation showing N jobs submitted
prettyload \$n \$tot
# ps -eo ppid | grep -w "\$master_pid" | wc -l
# Keeping track of the number of running child processes
while [ \$(pgrep -c -P\$master_pid) -ge \$MAX_PROC ]
do
# Hanging to limit parallel processes
sleep 1
done
# Setting region size longer than whole genome -> resized to contig
( tname=\$(echo \$tig | sed -n 's/>\([^ ]*\) .*/\1,/p' | tr -d '\n')
new_coord=\$(python2 src/convert_coord/contig2chr.py --pos1 "\${tname}0" \
grep ">" $OLD_REF \
| sed -n 's/>\([^ ]*\) .*/\1,0/p' \
| python2 src/convert_coord/contig2chr.py \
--region_size 1000000000 \
--include_input \
$OLD_REF \
$NEW_REF)
echo \${tname}\${new_coord} >> $tmp_dir/tmp-\$n.csv ) &
done
wait
# Merging all files into a single one
find $tmp_dir/ -name "*.csv" -type f -maxdepth 1 | \
xargs cat > $CORRESP_GFF
# Sort lines according to contig names
sort -k1,1 -o $CORRESP_GFF $CORRESP_GFF
$NEW_REF \
2> /dev/null \
| cut -d ',' -f2 --complement \
> $CORRESP_GFF
# insert header
sed -i "1s/^/tig,chr,start,region_size,transform\\n/" $CORRESP_GFF
Expand Down

0 comments on commit e20f8c0

Please sign in to comment.