-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRQCcontam.py
executable file
·52 lines (43 loc) · 1.17 KB
/
RQCcontam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python
import json
import sys
import urllib2
Input=sys.argv[1]
Link='https://rqc.jgi-psf.org/api/contam/report/'
libs=[]
InputFile=open(Input,"r")
OutFile=open("./RQCcontam.csv","w+")
for lines in InputFile:
line=lines.strip("\n")
line=line.split(" ")
libs.append(line[0])
InputFile.close()
Lib_list=",".join(libs)
Link=Link+Lib_list
contam_response=urllib2.urlopen(Link)
data=json.load(contam_response)
Libraries=[]
Library=""
artifact=""
contaminants=""
rrna=""
plastid=""
mito=""
ecoli=""
for stat in data['stats']:
for keys in stat:
if keys == "library_name":
library=str(stat[keys])
if keys == "artifact":
artifact=str(stat[keys]*100)
if keys == "contaminants":
contaminants=str(stat[keys]*100)
if keys == "rrna":
rrna=str(stat[keys]*100)
if keys == "plastid":
plastid=str(stat[keys]*100)
if keys == "mitochondrion":
mito=str(stat[keys]*100)
if keys == "ecoli_combined":
ecoli=str(stat[keys]*100)
OutFile.write(library+","+artifact+","+contaminants+","+rrna+","+plastid+","+mito+","+ecoli+"\n")