7b7e13b225417cda1b010036bb13394a8c1e790c angie Mon Mar 23 18:13:36 2020 -0700 Updating nextstrainNcov/doUpdate.sh to produce less output and be smarter about the true file date. refs #25188 diff --git src/hg/utils/otto/nextstrainNcov/doUpdate.sh src/hg/utils/otto/nextstrainNcov/doUpdate.sh index 13a973e..b7df924 100755 --- src/hg/utils/otto/nextstrainNcov/doUpdate.sh +++ src/hg/utils/otto/nextstrainNcov/doUpdate.sh @@ -1,52 +1,60 @@ #!/bin/bash -set -xbeEu -o pipefail +set -beEu -o pipefail # Do not modify this script, modify the source tree copy: # kent/src/hg/utils/nextstrainNcov/doUpdate.sh ottoDir=/hive/data/outside/otto/nextstrainNcov chromSizes=/hive/data/genomes/wuhCor1/chrom.sizes gbdbDir=/gbdb/wuhCor1/nextstrain cd $ottoDir +# The file is named .json, but is actually gzipped, so gunzip it. curl -s http://data.nextstrain.org/ncov.json | gunzip -c > ncov.json -if [ ! ncov.json -nt old.ncov.json ]; then - echo "Not newer" +curl -s -I http://data.nextstrain.org/ncov.json \ +| grep Last-Mod | sed -re 's/Last-Modified: //; s/\r//;' \ + > ncov.json.date +latestDate=$(cat ncov.json.date) +oldDate=$(cat old.ncov.json.date) +if [ $(date -d "$latestDate" +%s) -le $(date -d "$oldDate" +%s) ]; then + echo "Not newer than $(cat old.ncov.json.date)" exit 0 fi today=`date +%F` mkdir -p $today cp -p ncov.json $today mv ncov.json old.ncov.json +mv ncov.json.date old.ncov.json.date -cd $today +runDir=$ottoDir/$today +cd $runDir #Generate bed and VCF files $ottoDir/nextstrain.py # bgzip & tabix the VCF bgzip -f nextstrainSamples.vcf tabix -p vcf nextstrainSamples.vcf.gz # bigBed-ify the gene names and "clades" -bedToBigBed -type=bed4 -tab nextstrainGene.bed $chromSizes \ +bedToBigBed -type=bed4 -tab -verbose=0 nextstrainGene.bed $chromSizes \ nextstrainGene.bb sort -k2n,2n nextstrainClade.bed > nextstrainClade.sorted.bed -bedToBigBed -as=$ottoDir/nextstrainClade.as -type=bed12+2 -tab \ +bedToBigBed -as=$ottoDir/nextstrainClade.as -type=bed12+2 -tab -verbose=0 \ nextstrainClade.sorted.bed $chromSizes \ nextstrainClade.bb # Archive mkdir -p $ottoDir/archive/$today -cp -p `pwd`/nextstrainGene.bb `pwd`/nextstrainClade.bb `pwd`/nextstrainSamples.vcf.gz{,.tbi} \ +cp -p $runDir/nextstrainGene.bb $runDir/nextstrainClade.bb $runDir/nextstrainSamples.vcf.gz{,.tbi} \ $ottoDir/archive/$today -cp -p `pwd`/ncov.json $ottoDir/archive/$today +cp -p $runDir/ncov.json $ottoDir/archive/$today # Install -ln -sf `pwd`/nextstrainGene.bb `pwd`/nextstrainClade.bb `pwd`/nextstrainSamples.vcf.gz{,.tbi} \ +ln -sf $runDir/nextstrainGene.bb $runDir/nextstrainClade.bb $runDir/nextstrainSamples.vcf.gz{,.tbi} \ $gbdbDir/ -echo "Updated nextstrain/ncov `date`" +echo "Updated nextstrain/ncov `date` (ncov.json date $latestDate)"