Entering edit mode
2.2 years ago
katieostrouchov
▴
30
The following bash code generates an empty .json file named by the first line it read from the text file and never proceeds to the command cat in the for loop command below or proceeds to read the next line in the text file. What should I change in this for loop to work with the conda ncbi_datasets summary command?
For loop bash code:
cat > species.txt
Dubosiella newyorkensis
Bacteroides thetaiotaomicron
ctrl^D
SPECIES="species.txt"
while read line; do
FNAM="${line/ /_}"
datasets summary genome taxon "$line" --reference --limit all > ${FNAM}.json
cat ${FNAM}.json | jq -r '.assemblies[].assembly|[.assembly_accession,.org.tax_id,.org.sci_name] | @text' > ./lists/species/${FNAM}.txt
done <$SPECIES
Successful bash code without for loop for single entry:
datasets summary genome taxon "Bacteroides thetaiotaomicron" --reference --limit all > Bacteroidesthetaiotaomicron.json
cat Bacteroidesthetaiotaomicron.json | jq -r '.assemblies[].assembly|[.assembly_accession,.org.tax_id,.org.sci_name] | @text' > ./lists/species/Bacteroidesthetaiotaomicron.txt