...
 
Commits (2)
......@@ -13,8 +13,17 @@ Entrez.api_key = os.environ.get("NCBI_API_KEY", None)
def cache_json(function):
mem_cache = {}
def wrapper(*args):
path = ".cached/%s.%s.json" % (function.__name__, "--".join(args))
if not cache_json.disk_cache_enabled:
try:
return mem_cache[path]
except KeyError:
rv = function(*args)
mem_cache[path] = rv
return rv
try:
with open(path, 'r') as file:
return json.loads(file.read())
......@@ -28,6 +37,9 @@ def cache_json(function):
return wrapper
cache_json.disk_cache_enabled = True
@cache_json
def bio_sample_record(identifier):
with Entrez.esearch(db="biosample", retmax=2, term=identifier) as handle:
......@@ -158,7 +170,10 @@ if __name__ == '__main__':
parser.add_argument('-i', '--input', default='genomes_proks815-genomesonnovember.sample.csv', help="file to read")
parser.add_argument('-d', '--delimiter', default='\t', help="delimiter to use in both input and output file")
parser.add_argument('-v', dest='verbose', action='store_true')
parser.add_argument('--no-cache', dest='no_cache', action='store_true', help="Neither use or save to file cache")
args = parser.parse_args()
if args.no_cache:
cache_json.disk_cache_enabled = False
output_header = ["Strain", "BioSample", "Assembly", "Date", "Location", "Source", "Origin", "Host",
"Sequencing", "Assembling", "Coverage"]
......
......@@ -8,3 +8,13 @@ Klebsiella pneumoniae BK13043 SAMN06701573 PRJNA376414 Proteobacteria Gammaprot
Klebsiella pneumoniae KPN1482 SAMN06438459 PRJNA376414 Proteobacteria Gammaproteobacteria GCA_002156745.1 5.96528 56.6651 chromosome:NZ_CP020841.1/CP020841.1; plasmid pKPN1482-1:NZ_CP020842.1/CP020842.1; plasmid pKPN1482-2:NZ_CP020843.1/CP020843.1; plasmid pKPN1482-3:NZ_CP020844.1/CP020844.1; plasmid pKPN1482-4:NZ_CP020846.1/CP020846.1; plasmid pKPN1482-5:NZ_CP020845.1/CP020845.1 - 6 6151 5798 2017/05/23 2017/05/25 Complete Genome ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/002/156/745/GCF_002156745.1_ASM215674v1 ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/156/745/GCA_002156745.1_ASM215674v1
Klebsiella pneumoniae KP64 SAMD00059741 PRJDB5929 Proteobacteria Gammaproteobacteria GCA_003574255.1 5.72179 56.9658 chromosome:NZ_AP018750.1/AP018750.1; plasmid pKP6401:NZ_AP018751.1/AP018751.1; plasmid pKP6402:NZ_AP018752.1/AP018752.1 - 3 5650 5365 2018/07/20 2019/08/29 Complete Genome ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/003/574/255/GCF_003574255.1_ASM357425v1 ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/574/255/GCA_003574255.1_ASM357425v1
Klebsiella pneumoniae KP67 SAMD00059744 PRJDB5929 Proteobacteria Gammaproteobacteria GCA_003574275.1 5.7218 56.9658 chromosome:NZ_AP018753.1/AP018753.1; plasmid pKP6701:NZ_AP018754.1/AP018754.1; plasmid pKP6702:NZ_AP018755.1/AP018755.1 - 3 5647 5365 2018/07/20 2019/08/29 Complete Genome ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCF/003/574/275/GCF_003574275.1_ASM357427v1 ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/574/275/GCA_003574275.1_ASM357427v1
Klebsiella pneumoniae C2 SAMN07793216 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002857375.1 4.70855 57.4 - PIBU01 2832 6513 6293 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/857/375/GCA_002857375.1_ASM285737v1
Klebsiella pneumoniae D11 SAMN07793231 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002856225.1 4.88762 57.4 - PICD01 2967 6842 6618 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/856/225/GCA_002856225.1_ASM285622v1
Klebsiella pneumoniae D64 SAMN07793304 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002856805.1 4.8774 57.4 - PIEP01 3053 6937 6694 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/856/805/GCA_002856805.1_ASM285680v1
Klebsiella pneumoniae BC_4553 SAMN09298431 PRJNA377546 Proteobacteria Gammaproteobacteria GCA_003325795.1 5.54197 57 - QORQ01 4149 8676 8409 2018/07/17 2018/07/17 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/325/795/GCA_003325795.1_ASM332579v1
Klebsiella pneumoniae C22 SAMN07793250 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002856605.1 4.82255 57.4 - PICS01 3333 6913 6671 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/856/605/GCA_002856605.1_ASM285660v1
Klebsiella pneumoniae LIM955 SAMN06462042 PRJNA377546 Proteobacteria Gammaproteobacteria GCA_003095435.1 5.9335 56.3 - QEFS01 4660 9391 9014 2018/05/06 2018/05/06 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/095/435/GCA_003095435.1_ASM309543v1
Klebsiella pneumoniae D3 SAMN07793222 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002856715.1 4.66129 57.3 - PIBY01 3567 7081 6858 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/856/715/GCA_002856715.1_ASM285671v1
Klebsiella pneumoniae A1 SAMN07793212 PRJNA414542 Proteobacteria Gammaproteobacteria GCA_002857385.1 4.48439 57.6 - PIBR01 3625 6911 6710 2018/01/03 2018/01/03 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/002/857/385/GCA_002857385.1_ASM285738v1
Klebsiella pneumoniae NCTC 418 SAMN08918337 PRJNA449808 Proteobacteria Gammaproteobacteria GCA_003076915.1 (partial) 5.47598 57.3239 chromosome:CP028915.1; plasmid unnamed1:CP028916.1 - 2 5501 5200 2018/05/02 2018/05/02 Chromosome - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/003/076/915/GCA_003076915.1_ASM307691v1
Klebsiella pneumoniae HEE2017 SAMN11474736 PRJNA533969 Proteobacteria Gammaproteobacteria GCA_008033425.1 (partial) 0.481368 51.4502 plasmid pOXA48:CM017776.1 SZUX01 638 944 896 2019/08/19 2019/08/23 Contig - ftp://ftp.ncbi.nlm.nih.gov/genomes/all/GCA/008/033/425/GCA_008033425.1_ASM803342v1