Created
November 22, 2010 22:11
-
-
Save bbarry/710816 to your computer and use it in GitHub Desktop.
hits
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
import MetagenomeDB as mdb | |
names = ['check1', 'check2', 'check3'] | |
def run(): | |
c = mdb.Collection.find_one({"name": "NL10_1002_vRNA:contigs-strict"}) | |
output=[] | |
for sequence in c.list_sequences(): | |
if (not "alignments" in sequence): | |
continue | |
for hit in sequence["alignments"]: | |
checks= [ | |
("rdrp" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()), | |
("virus" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()) and 0.02 > (hit["score"]["e_value"]), | |
("rdrp" in hit["hit"]["description"].lower()) and ("rpstblastn" in hit["run"]["algorithm"]["name"].lower()) | |
] | |
names = ['check1', 'check2', 'check3'] | |
l=[names[v] for v in range(0,3) if checks[v]] | |
m=[names[x] for x in range(0,3) if checks[x] else ''] | |
score=len(l) | |
if score>0: | |
output.append({ | |
'name': sequence.get_property("name"), | |
'score': score, | |
'checks_passed': ' '.join(l), | |
'e_value': hit["score"]["e_value"], | |
'checks_as_list': m | |
}) | |
return output | |
items = run() | |
print len(item) | |
output=[] | |
for item in items: | |
output.append(item['name']) | |
output.append(':') | |
output.append(str(item['score'])) | |
output.append(':') | |
output.append(str(item['e_value'])) | |
output.append(':') | |
output.append(':'.join(item['checks_as_list'])) | |
output.append("\n") | |
print ''.join(output) |
from cStringIO import StringIO
def Score(l):
return len([item for item in l if item])
import MetagenomeDB as mdb
c = mdb.Collection.find_one({"name": "NL10_1006_vRNA:contigs-strict"})
output=[]
for sequence in c.list_sequences():
if (not "alignments" in sequence):
continue
for hit in sequence["alignments"]:
checks=[("rdrp" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()),
("virus" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()) and 0.02 > (hit["score"]["e_value"]),
("rdrp" in hit["hit"]["description"].lower()) and ("rpstblastn" in hit["run"]["algorithm"]["name"].lower())]
if Score(checks)>1:
output.append('')
print ''.join(output)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import MetagenomeDB as mdb
c = mdb.Collection.find_one({"name": "NL10_1006_vRNA:contigs-strict"})
for sequence in c.list_sequences():
if (not "alignments" in sequence):
continue
for hit in sequence["alignments"]:
if ("rdrp" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()):
print "RdRp hit in BlastX " + sequence.get_property("name") + " " + str(hit["score"]["e_value"])
if ("virus" in hit["hit"]["description"].lower()) and ("blastx" in hit["run"]["algorithm"]["name"].lower()) and 0.02 > (hit["score"]["e_value"]):
print "Significant BlastX Virus Hit " + sequence.get_property("name") + " " + str(hit["score"]["e_value"])
if ("rdrp" in hit["hit"]["description"].lower()) and ("rpstblastn" in hit["run"]["algorithm"]["name"].lower()):
print "Conserved Domain RdRp Hit " + sequence.get_property("name") + " " + str(hit["score"]["e_value"])