abdea7a81b3d511adaee6300277721a804f5581f angie Tue Mar 30 11:57:47 2021 -0700 Ongoing fixes for odd characters in sequence names and other pipeline tweaks. diff --git src/hg/utils/otto/sarscov2phylo/updateCombinedTree.sh src/hg/utils/otto/sarscov2phylo/updateCombinedTree.sh index 8e6cf6e..5a8eb09 100755 --- src/hg/utils/otto/sarscov2phylo/updateCombinedTree.sh +++ src/hg/utils/otto/sarscov2phylo/updateCombinedTree.sh @@ -21,49 +21,52 @@ ncbiDir=$ottoDir/ncbi.latest cogUkDir=$ottoDir/cogUk.latest cncbDir=$ottoDir/cncb.latest gisaidDir=/hive/users/angie/gisaid minReal=20000 ref2bit=/hive/data/genomes/wuhCor1/wuhCor1.2bit epiToPublic=$gisaidDir/epiToPublicAndDate.latest scriptDir=$(dirname "${BASH_SOURCE[0]}") source $scriptDir/util.sh today=$(date +%F) cd $ottoDir/$today prevProtobufMasked=$ottoDir/$prevDate/gisaidAndPublic.$prevDate.masked.pb -# Use Yatish's latest usher and matUtils usherDir=~angie/github/yatish_usher usher=$usherDir/build/usher matUtils=$usherDir/build/matUtils # Make lists of sequences already in the tree. -$matUtils summary -i $prevProtobufMasked -s >(tail -n+2 | cut -f 1 > prevNames) +# matUtils creates full paths for output files, defaulting to current directory, so can't +# output to named pipe because it becomes $cwd//dev/fd/63 ... +$matUtils summary -i $prevProtobufMasked -s prevSamples +tail -n+2 prevSamples | cut -f 1 > prevNames awk -F\| '{if ($3 == "") { print $1; } else { print $2; } }' prevNames \ | grep -E '^[A-Z]{2}[0-9]{6}\.[0-9]' > prevGbAcc awk -F\| '{if ($3 == "") { print $1; } else { print $2; } }' prevNames \ | grep -E '^(England|Northern|Scotland|Wales)' > prevCogUk awk -F\| '{if ($3 == "") { print $1; } else { print $2; } }' prevNames \ | grep -E '^EPI_ISL_' > prevGisaid # Add public sequences that have been mapped to GISAID sequences to prevGisaid. grep -Fwf prevGbAcc $epiToPublic | cut -f 1 >> prevGisaid grep -Fwf prevCogUk $epiToPublic | cut -f 1 >> prevGisaid wc -l prev* # Get new GenBank sequences with at least $minReal non-N bases. +#*** TODO: exclude seqs already in tree in their GISAID forms xzcat $ncbiDir/genbank.fa.xz \ | faSomeRecords -exclude stdin prevGbAcc newGenBank.fa faSize -veryDetailed newGenBank.fa \ | tawk '$4 < '$minReal' {print $1;}' \ > gbTooSmall # NCBI also includes NC_045512 in the download, but that's our reference, so... exclude that too. fastaNames newGenBank.fa | grep NC_045512 >> gbTooSmall faSomeRecords -exclude newGenBank.fa gbTooSmall newGenBank.filtered.fa faSize newGenBank.filtered.fa # Get new COG-UK sequences with at least $minReal non-N bases. xzcat $cogUkDir/cog_all.fasta.xz \ | faSomeRecords -exclude stdin prevCogUk newCogUk.fa faSize -veryDetailed newCogUk.fa \ | tawk '$4 < '$minReal' {print $1;}' \ @@ -212,41 +215,47 @@ # Add pangolin lineage annotations to protobuf. Use pangoLEARN training samples; # convert EPI IDs to public to match tree IDs. tail -n+2 ~angie/github/pangoLEARN/pangoLEARN/data/lineages.metadata.csv \ | awk -F, '{print $7 "\t" $2;}' \ | sort > epiExemplarToLineage subColumn -miss=/dev/null 1 epiExemplarToLineage \ <(cut -f 1,2 $gisaidDir/epiToPublicAndDate.$today) stdout \ | sort > idExemplarToLineage cut -f 2 $renaming | grep -Fwf <(cut -f 1 idExemplarToLineage) \ | awk -F\| '{ if ($3 == "") { print $1 "\t" $0 } else { print $2 "\t" $0; } }' \ | sort > idExemplarToName join -t$'\t' idExemplarToName idExemplarToLineage \ | tawk '{print $3, $2;}' \ | sort > lineageToName -time $matUtils annotate -T 50 \ +linFile=lineageToName + +# Until pangoLEARN training is done, use pango-designation file for now. +#linFile=/hive/users/angie/matLineages/linToPublicPlusGisaidName.2021-03-16 + +#*** +##***time $matUtils annotate -T 50 \ +time ~angie/github/usher/build/matUtils annotate -T 50 \ -i gisaidAndPublic.$today.masked.nextclade.pb \ - -c lineageToName \ + -c $linFile \ -o gisaidAndPublic.$today.masked.nextclade.pangolin.pb \ >& annotate.pangolin.out mv gisaidAndPublic.$today.masked{,.unannotated}.pb ln gisaidAndPublic.$today.masked.nextclade.pangolin.pb gisaidAndPublic.$today.masked.pb # Extract public samples from tree -$matUtils summary -i gisaidAndPublic.$today.masked.pb -s >(tail -n+2 | cut -f 1 > newNames) +$matUtils summary -i gisaidAndPublic.$today.masked.pb -s newSamples +tail -n+2 newSamples | cut -f 1 > newNames grep -v EPI_ISL_ newNames > newPublicNames $matUtils extract -i gisaidAndPublic.$today.masked.pb \ -s newPublicNames \ -O -o public.$today.masked.pb for dir in /usr/local/apache/cgi-bin{-angie,-beta,}/hgPhyloPlaceData/wuhCor1; do ln -sf `pwd`/gisaidAndPublic.$today.masked.pb $dir/public.plusGisaid.latest.masked.pb ln -sf `pwd`/gisaidAndPublic.$today.metadata.tsv.gz \ $dir/public.plusGisaid.latest.metadata.tsv.gz ln -sf `pwd`/hgPhyloPlace.plusGisaid.description.txt $dir/public.plusGisaid.latest.version.txt done -# Clean up -nice xz -f new*fa &