Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting the download/*_genome.csv files into a species list #58

Open
taylorreiter opened this issue Mar 14, 2024 · 0 comments
Open

Comments

@taylorreiter
Copy link
Member

PreHGT runs at the genus level to pull in (pseudo) pangenome information, which is used to estimate contamination vs. real transfer events.

Right now, we don't do a good job of reporting how many/which species are represented for each genera. Below I include some code I recently used to get the species (organism name) information from ncbi based on the genome accession (`GCA*/GCF*).

I ran this on all files matching download/*_genome.csv

Install tools

conda install -c conda-forge ncbi-datasets-cli jq

collect genome accessions without csv headers

for infile in *csv
do
  cat $infile | tail -n +2 >> genomes.csv
done

get species (organism name)

while IFS= read -r accession
do
    datasets summary genome accession "$accession" | jq -r '.reports[] | [.accession, .organism.organism_name] | @csv'
done < <(awk -F, 'NR>1 {match($2, /(GCA|GCF)_[0-9]+\.[0-9]+/, m); print m[0]}' genomes.csv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant