-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from UPHL-BioNGS/update20230802
Update20230802
- Loading branch information
Showing
26 changed files
with
268 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
|
||
''' | ||
Author: Erin Young | ||
Description: | ||
This script is to get some genome accession from NCBI datasets | ||
EXAMPLE: | ||
python3 datasets_download.py taxon hits | ||
''' | ||
|
||
import subprocess | ||
import sys | ||
|
||
taxon = sys.argv[1] | ||
genus, species = taxon.replace('[', '').replace(']', '').split('_') | ||
print("Looking for accessions for " + genus + " " + species ) | ||
outfile = open('datasets/' + genus + "_" + species + '_genomes.csv', "w") | ||
|
||
try: | ||
hits = sys.argv[2] | ||
except: | ||
hits = '5' | ||
|
||
# putting in the header | ||
outfile.write('accession,assminfo-refseq-category,assminfo-level,organism-name,assmstats-total-ungapped-len\n') | ||
|
||
# Getting representative genomes | ||
rep = subprocess.Popen(['datasets', 'summary', 'genome', 'taxon', '"' + genus + ' ' + species + '"', '--reference', '--limit', hits, '--as-json-lines'], stdout = subprocess.PIPE) | ||
dft = subprocess.check_output(['dataformat', 'tsv', 'genome', '--fields' , 'accession,assminfo-refseq-category,assminfo-level,organism-name,assmstats-total-ungapped-len'], stdin = rep.stdout, universal_newlines= True, text='str') | ||
rep.wait() | ||
for line in dft.split('\n'): | ||
if 'Ungapped Length' not in line and line: | ||
if int(line.split('\t')[4]) < 15000000: | ||
outfile.write(line.replace('\t',',') + '\n') | ||
|
||
# Getting additional genomes | ||
oth = subprocess.Popen(['datasets', 'summary', 'genome', 'taxon', '"' + genus + ' ' + species + '"', '--limit', hits, '--as-json-lines'], stdout = subprocess.PIPE) | ||
df2 = subprocess.check_output(['dataformat', 'tsv', 'genome', '--fields' , 'accession,assminfo-refseq-category,assminfo-level,organism-name,assmstats-total-ungapped-len'], stdin = oth.stdout, universal_newlines= True, text='str') | ||
oth.wait() | ||
for line in df2.split('\n'): | ||
if 'Ungapped Length' not in line and line: | ||
if int(line.split('\t')[4]) < 15000000: | ||
outfile.write(line.replace('\t',',') + '\n') | ||
|
||
outfile.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/python3 | ||
|
||
########################################## | ||
# written by Erin Young # | ||
# for creating summary files with the # | ||
# sample id for Grandeur # | ||
########################################## | ||
|
||
import os | ||
import sys | ||
|
||
out = sys.argv[2] | ||
spl = sys.argv[4] | ||
|
||
if not os.path.exists(sys.argv[1]): | ||
print("File " + sys.argv[1] + " does not exist. Exiting.") | ||
exit() | ||
|
||
coms = 0 | ||
tabs = 0 | ||
with open(sys.argv[1]) as file: | ||
first_line = file.readline() | ||
coms = first_line.count('\t') | ||
tabs = first_line.count('\t') | ||
|
||
if tabs > coms: | ||
delim = '\t' | ||
print("Predicting tab delimited") | ||
else: | ||
delim = ',' | ||
print("Predicting comma delimited") | ||
|
||
with open(sys.argv[1], 'r') as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
print(line) | ||
print(line.split(delim)) | ||
|
||
outfile = open(sys.argv[2], "w") | ||
|
||
final_delim = ',' | ||
header = 'shouldntexist' | ||
|
||
# TODO: turn this into a dict | ||
if sys.argv[3] == 'mlst': | ||
final_delim = '\t' | ||
header = 'PubMLST' | ||
outfile.write('sample\tfilename\tmatching PubMLST scheme\tST\tID1\tID2\tID3\tID4\tID5\tID6\tID7\tID8\tID9\tID10\tID11\tID12\tID13\tID14\tID15\n') | ||
elif sys.argv[3] == 'shigatyper': | ||
final_delim = '\t' | ||
header = 'Number' | ||
elif sys.argv[3] == 'kleborate': | ||
final_delim = '\t' | ||
header = 'largest_contig' | ||
elif sys.argv[3] == 'plasmidfinder' : | ||
final_delim = '\t' | ||
header = 'Accession number' | ||
elif sys.argv[3] == 'emmtyper': | ||
outfile.write('sample\tIsolate name\tNumber of BLAST hits\tNumber of clusters\tPredicted emm-type\tPosition(s)\tPossible emm-like alleles\temm-like position(s)\tEMM cluster\n') | ||
final_delim = '\t' | ||
header = 'Number of BLAST hits' | ||
elif sys.argv[3] == 'serotypefinder': | ||
final_delim = '\t' | ||
header = 'HSP length' | ||
|
||
print("Using final delim " + final_delim + " with sample " + spl + " for " + sys.argv[3]) | ||
|
||
with open(sys.argv[1]) as file: | ||
lines = file.readlines() | ||
for line in lines: | ||
if header in line: | ||
replace = line.replace(delim, final_delim) | ||
outfile.write('sample' + final_delim + replace) | ||
else: | ||
replace = line.replace(delim, final_delim) | ||
outfile.write(spl + final_delim + replace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.