Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions update_catalog/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Scripts to update the on-disk catalog of SRA metagenomes

Original source: [bluegenes/2022-magsearch-tr](https://github.com/bluegenes/2022-magsearch-tr/)


36 changes: 36 additions & 0 deletions update_catalog/Snakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Original author: Luiz Irber (except for the parameter fiddling :)

Updated by Tessa Pierce and CTB.
"""

configfile: "config.yml"

rule download_catalog_from_ncbi:
output: "metagenomes_source.csv"
shell: """
wget -O {output} 'http://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?save=efetch&db=sra&rettype=runinfo&term=("METAGENOMIC"[source] NOT amplicon[All Fields])'
"""

rule catalog_local_metagenomes:
input:
source_catalog = "metagenomes_source.csv"
output:
catalog = config['catalog_out']
run:
import csv
from pathlib import Path

# CTB: what the heck is this file? :laugh:
sraids = set(Path("/group/ctbrowngrp/irber/sra_search/inputs/mash_sraids.txt").read_text().split('\n'))

with open("metagenomes_source") as fp:
data = csv.DictReader(fp, delimiter=',')
for dataset in data:
sraids.add(dataset['Run'])

with open(output[0], 'w') as fout:
for sraid in sraids:
sig_path = Path(config['wort_sigs']) / f"{sraid}.sig"
if sig_path.exists():
fout.write(f"{sig_path}\n")
4 changes: 4 additions & 0 deletions update_catalog/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wort_sigs: /group/ctbrowngrp/irber/data/wort-data/wort-sra/sigs

# farm location: /group/ctbrowngrp/sra_search/catalogs/metagenomes
catalog_out: "metagenomes_catalog_latest.txt"
3 changes: 3 additions & 0 deletions update_catalog/download_catalog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

wget -O metagenomes_source.csv 'http://trace.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?save=efetch&db=sra&rettype=runinfo&term=("METAGENOMIC"[source] NOT amplicon[All Fields])'