annotate galaxy_prediction.py.2 @ 0:917a05a03ac9 draft

Uploaded
author jjjjia
date Tue, 14 Aug 2018 17:18:49 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
1 #!/home/jjjjia/.conda/envs/py36/bin/python
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
2
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
3 #$ -S /home/jjjjia/.conda/envs/py36/bin/python
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
4 #$ -V # Pass environment variables to the job
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
5 #$ -N CPO_pipeline # Replace with a more specific job name
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
6 #$ -wd /home/jjjjia/testCases # Use the current working dir
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
7 #$ -pe smp 8 # Parallel Environment (how many cores)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
8 #$ -l h_vmem=11G # Memory (RAM) allocation *per core*
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
9 #$ -e ./logs/$JOB_ID.err
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
10 #$ -o ./logs/$JOB_ID.log
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
11 #$ -m ea
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
12 #$ -M bja20@sfu.ca
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
13
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
14 #./prediction.py -i ~/testCases/cpoResults/contigs/BC11-Kpn005_S2.fa -m ~/testCases/predictionResultsQsubTest/predictions/BC11-Kpn005_S2.mlst -c ~/testCases/predictionResultsQsubTest/predictions/BC11-Kpn005_S2.recon/contig_report.txt -f ~/testCases/predictionResultsQsubTest/predictions/BC11-Kpn005_S2.recon/mobtyper_aggregate_report.txt -a ~/testCases/predictionResultsQsubTest/predictions/BC11-Kpn005_S2.cp -r ~/testCases/predictionResultsQsubTest/predictions/BC11-Kpn005_S2.rgi.txt -e "Klebsiella"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
15 import subprocess
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
16 import pandas
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
17 import optparse
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
18 import os
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
19 import datetime
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
20 import sys
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
21 import time
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
22 import urllib.request
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
23 import gzip
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
24 import collections
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
25 import json
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
26 import numpy
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
27
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
28
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
29 debug = False #debug skips the shell scripts and also dump out a ton of debugging messages
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
30
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
31 if not debug:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
32 #parses some parameters
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
33 parser = optparse.OptionParser("Usage: %prog [options] arg1 arg2 ...")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
34 #required
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
35 #MLSTHIT, mobsuite, resfinder, rgi, mlstscheme
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
36 parser.add_option("-i", "--id", dest="id", type="string", help="identifier of the isolate")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
37 parser.add_option("-m", "--mlst", dest="mlst", type="string", help="absolute file path to mlst result")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
38 parser.add_option("-c", "--mobfinderContig", dest="mobfinderContig", type="string", help="absolute path to mobfinder aggregate result")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
39 parser.add_option("-f", "--mobfinderAggregate", dest="mobfinderAggregate", type="string", help="absolute path to mobfinder plasmid results")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
40 parser.add_option("-a", "--abricate", dest="abricate", type="string", help="absolute path to abricate results")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
41 parser.add_option("-r", "--rgi", dest="rgi", type="string", help="absolute path to rgi results")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
42 parser.add_option("-e", "--expected", dest="expectedSpecies", default="NA/NA/NA", type="string", help="expected species of the isolate")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
43 parser.add_option("-s", "--mlst-scheme", dest="mlstScheme", default= "./scheme_species_map.tab", type="string", help="absolute file path to mlst scheme")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
44
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
45 #parallelization, useless, these are hard coded to 8cores/64G RAM
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
46 #parser.add_option("-t", "--threads", dest="threads", default=8, type="int", help="number of cpu to use")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
47 #parser.add_option("-p", "--memory", dest="memory", default=64, type="int", help="memory to use in GB")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
48
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
49 (options,args) = parser.parse_args()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
50 #if len(args) != 8:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
51 #parser.error("incorrect number of arguments, all 7 is required")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
52 curDir = os.getcwd()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
53 ID = str(options.id).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
54 mlst = str(options.mlst).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
55 mobfindercontig = str(options.mobfinderContig).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
56 mobfinderaggregate = str(options.mobfinderAggregate).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
57 abricate = str(options.abricate).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
58 rgi = str(options.rgi).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
59 expectedSpecies = str(options.expectedSpecies).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
60 mlstScheme = str(options.mlstScheme).lstrip().rstrip()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
61 outputDir = "./"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
62 print(mlst)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
63 print(mobfindercontig)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
64 print(mobfinderaggregate)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
65 print(abricate)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
66 print(rgi)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
67 print(expectedSpecies)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
68 print(mlstScheme)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
69 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
70 curDir = os.getcwd()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
71 ID = "BC11"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
72 mlst = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\predictions\BC11-Kpn005_S2.mlst"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
73 mobfindercontig = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\predictions\BC11-Kpn005_S2.recon\contig_report.txt"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
74 mobfinderaggregate = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\predictions\BC11-Kpn005_S2.recon\mobtyper_aggregate_report.txt"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
75 abricate = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\predictions\BC11-Kpn005_S2.cp"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
76 rgi = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\predictions\BC11-Kpn005_S2.rgi.txt"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
77 expectedSpecies = "Escherichia coli"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
78 mlstScheme = "D:\OneDrive\ProjectCDC\ProjectCDCInPython\ProjectCDCInPython\pipelineTest\scheme_species_map.tab"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
79 outputDir = "./"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
80
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
81 #region result objects
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
82 #define some objects to store values from results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
83 #//TODO this is not the proper way of get/set private object variables. every value has manually assigned defaults intead of specified in init(). Also, use property(def getVar, def setVar).
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
84 class starFinders(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
85 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
86 self.file = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
87 self.sequence = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
88 self.start = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
89 self.end = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
90 self.gene = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
91 self.shortGene = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
92 self.coverage = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
93 self.coverage_map = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
94 self.gaps = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
95 self.pCoverage = 100.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
96 self.pIdentity = 100.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
97 self.database = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
98 self.accession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
99 self.product = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
100 self.source = "chromosome"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
101 self.row = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
102
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
103 class PlasFlowResult(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
104 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
105 self.sequence = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
106 self.length = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
107 self.label = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
108 self.confidence = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
109 self.usefulRow = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
110 self.row = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
111
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
112 class MlstResult(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
113 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
114 self.file = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
115 self.speciesID = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
116 self.seqType = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
117 self.scheme = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
118 self.species = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
119 self.row=""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
120
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
121 class mobsuiteResult(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
122 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
123 self.file_id = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
124 self.cluster_id = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
125 self.contig_id = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
126 self.contig_num = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
127 self.contig_length = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
128 self.circularity_status = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
129 self.rep_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
130 self.rep_type_accession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
131 self.relaxase_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
132 self.relaxase_type_accession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
133 self.mash_nearest_neighbor = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
134 self.mash_neighbor_distance = 0.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
135 self.repetitive_dna_id = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
136 self.match_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
137 self.score = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
138 self.contig_match_start = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
139 self.contig_match_end = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
140 self.row = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
141
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
142 class mobsuitePlasmids(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
143 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
144 self.file_id = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
145 self.num_contigs = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
146 self.total_length = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
147 self.gc = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
148 self.rep_types = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
149 self.rep_typeAccession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
150 self.relaxase_type= ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
151 self.relaxase_type_accession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
152 self.mpf_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
153 self.mpf_type_accession= ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
154 self.orit_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
155 self.orit_accession = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
156 self.PredictedMobility = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
157 self.mash_nearest_neighbor = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
158 self.mash_neighbor_distance = 0.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
159 self.mash_neighbor_cluster= 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
160 self.row = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
161 class RGIResult(object):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
162 def __init__(self):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
163 self.ORF_ID = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
164 self.Contig = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
165 self.Start = -1
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
166 self.Stop = -1
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
167 self.Orientation = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
168 self.Cut_Off = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
169 self.Pass_Bitscore = 100000
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
170 self.Best_Hit_Bitscore = 0.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
171 self.Best_Hit_ARO = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
172 self.Best_Identities = 0.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
173 self.ARO = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
174 self.Model_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
175 self.SNPs_in_Best_Hit_ARO = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
176 self.Other_SNPs = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
177 self.Drug_Class = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
178 self.Resistance_Mechanism = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
179 self.AMR_Gene_Family = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
180 self.Predicted_DNA = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
181 self.Predicted_Protein = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
182 self.CARD_Protein_Sequence = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
183 self.Percentage_Length_of_Reference_Sequence = 0.00
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
184 self.ID = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
185 self.Model_ID = 0
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
186 self.source = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
187 self.row = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
188
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
189 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
190
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
191 #region useful functions
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
192 def read(path):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
193 return [line.rstrip('\n') for line in open(path)]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
194 def execute(command):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
195 process = subprocess.Popen(command, shell=False, cwd=curDir, universal_newlines=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
196
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
197 # Poll process for new output until finished
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
198 while True:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
199 nextline = process.stdout.readline()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
200 if nextline == '' and process.poll() is not None:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
201 break
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
202 sys.stdout.write(nextline)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
203 sys.stdout.flush()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
204
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
205 output = process.communicate()[0]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
206 exitCode = process.returncode
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
207
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
208 if (exitCode == 0):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
209 return output
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
210 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
211 raise subprocess.CalledProcessError(exitCode, command)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
212 def httpGetFile(url, filepath=""):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
213 if (filepath == ""):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
214 return urllib.request.urlretrieve(url)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
215 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
216 urllib.request.urlretrieve(url, filepath)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
217 return True
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
218 def gunzip(inputpath="", outputpath=""):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
219 if (outputpath == ""):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
220 with gzip.open(inputpath, 'rb') as f:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
221 gzContent = f.read()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
222 return gzContent
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
223 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
224 with gzip.open(inputpath, 'rb') as f:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
225 gzContent = f.read()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
226 with open(outputpath, 'wb') as out:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
227 out.write(gzContent)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
228 return True
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
229 def ToJson(dictObject, outputPath):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
230 #outDir = outputDir + '/summary/' + ID + ".json/"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
231 #if not (os.path.exists(outDir)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
232 #os.makedirs(outDir)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
233 #with open(outputPath, 'w') as f:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
234 #json.dump([ob.__dict__ for ob in dictObject.values()], f, ensure_ascii=False)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
235 return ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
236 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
237
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
238 #region functions to parse result files
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
239 def ParseMLSTResult(pathToMLSTResult, scheme):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
240 _mlstResult = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
241 scheme = pandas.read_csv(scheme, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
242 scheme = scheme.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
243
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
244 taxon = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
245 #record the scheme as a dictionary
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
246 taxon["-"] = "No MLST Match"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
247 for i in range(len(scheme.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
248 key = scheme.iloc[i,0]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
249 if (str(scheme.iloc[i,2]) == "nan"):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
250 value = str(scheme.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
251 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
252 value = str(scheme.iloc[i,1]) + " " + str(scheme.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
253
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
254 if (key in taxon.keys()):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
255 taxon[key] = taxon.get(key) + ";" + value
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
256 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
257 taxon[key] = value
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
258 #read in the mlst result
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
259 mlst = pandas.read_csv(pathToMLSTResult, delimiter='\t', header=None)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
260 _mlstHit = MlstResult()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
261
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
262 _mlstHit.file = mlst.iloc[0,0]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
263 _mlstHit.speciesID = (mlst.iloc[0,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
264 _mlstHit.seqType = str(mlst.iloc[0,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
265 for i in range(3, len(mlst.columns)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
266 _mlstHit.scheme += mlst.iloc[0,i] + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
267 _mlstHit.species = taxon[_mlstHit.speciesID]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
268 _mlstHit.row = "\t".join(str(x) for x in mlst.ix[0].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
269 _mlstResult[_mlstHit.speciesID]=_mlstHit
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
270
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
271 return _mlstResult
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
272
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
273 def ParsePlasmidFinderResult(pathToPlasmidFinderResult):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
274 #pipelineTest/contigs/BC110-Kpn005.fa contig00019 45455 45758 IncFIC(FII)_1 8-308/499 ========/=..... 8/11 59.52 75.65 plasmidfinder AP001918 IncFIC(FII)_1__AP001918
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
275 #example resfinder:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
276 #pipelineTest/contigs/BC110-Kpn005.fa contig00038 256 1053 OXA-181 1-798/798 =============== 0/0 100.00 100.00 bccdc AEP16366.1 OXA-48 family carbapenem-hydrolyzing class D beta-lactamase OXA-181
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
277
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
278 _pFinder = {} #***********************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
279 plasmidFinder = pandas.read_csv(pathToPlasmidFinderResult, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
280 plasmidFinder = plasmidFinder.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
281
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
282
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
283 for i in range(len(plasmidFinder.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
284 pf = starFinders()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
285 pf.file = str(plasmidFinder.iloc[i,0])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
286 pf.sequence = str(plasmidFinder.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
287 pf.start = int(plasmidFinder.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
288 pf.end = int(plasmidFinder.iloc[i,3])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
289 pf.gene = str(plasmidFinder.iloc[i,4])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
290 pf.shortGene = pf.gene[:pf.gene.index("_")]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
291 pf.coverage = str(plasmidFinder.iloc[i,5])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
292 pf.coverage_map = str(plasmidFinder.iloc[i,6])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
293 pf.gaps = str(plasmidFinder.iloc[i,7])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
294 pf.pCoverage = float(plasmidFinder.iloc[i,8])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
295 pf.pIdentity = float(plasmidFinder.iloc[i,9])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
296 pf.database = str(plasmidFinder.iloc[i,10])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
297 pf.accession = str(plasmidFinder.iloc[i,11])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
298 pf.product = str(plasmidFinder.iloc[i,12])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
299 pf.source = "plasmid"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
300 pf.row = "\t".join(str(x) for x in plasmidFinder.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
301 _pFinder[pf.gene]=pf
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
302 #row = "\t".join(str(x) for x in plasmidFinder.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
303 #plasmidFinderContigs.append(str(plasmidFinder.iloc[i,1]))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
304 #origins.append(str(plasmidFinder.iloc[i,4][:plasmidFinder.iloc[i,4].index("_")]))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
305 return _pFinder
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
306
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
307 def ParseMobsuiteResult(pathToMobsuiteResult):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
308 _mobsuite = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
309 mResult = pandas.read_csv(pathToMobsuiteResult, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
310 mResult = mResult.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
311
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
312 for i in range(len(mResult.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
313 mr = mobsuiteResult()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
314 mr.file_id = str(mResult.iloc[i,0])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
315 mr.cluster_id = str(mResult.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
316 if (mr.cluster_id == "chromosome"):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
317 break
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
318 mr.contig_id = str(mResult.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
319 mr.contig_num = mr.contig_id[(mr.contig_id.find("contig")+6):mr.contig_id.find("_len=")]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
320 mr.contig_length = int(mResult.iloc[i,3])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
321 mr.circularity_status = str(mResult.iloc[i,4])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
322 mr.rep_type = str(mResult.iloc[i,5])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
323 mr.rep_type_accession = str(mResult.iloc[i,6])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
324 mr.relaxase_type = str(mResult.iloc[i,7])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
325 mr.relaxase_type_accession = str(mResult.iloc[i,8])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
326 mr.mash_nearest_neighbor = str(mResult.iloc[i,9])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
327 mr.mash_neighbor_distance = float(mResult.iloc[i,10])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
328 mr.repetitive_dna_id = str(mResult.iloc[i,11])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
329 mr.match_type = str(mResult.iloc[i,12])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
330 if (mr.match_type == ""):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
331 mr.score = -1
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
332 mr.contig_match_start = -1
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
333 mr.contig_match_end = -1
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
334 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
335 mr.score = int(mResult.iloc[i,13])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
336 mr.contig_match_start = int(mResult.iloc[i,14])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
337 mr.contig_match_end = int(mResult.iloc[i,15])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
338 mr.row = "\t".join(str(x) for x in mResult.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
339 _mobsuite[mr.contig_id]=(mr)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
340 return _mobsuite
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
341
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
342 def ParseMobsuitePlasmids(pathToMobsuiteResult):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
343 _mobsuite = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
344 mResults = pandas.read_csv(pathToMobsuiteResult, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
345 mResults = mResults.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
346
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
347 for i in range(len(mResults.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
348 mr = mobsuitePlasmids()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
349 mr.file_id = str(mResults.iloc[i,0])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
350 mr.num_contigs = int(mResults.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
351 mr.total_length = int(mResults.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
352 mr.gc = int(mResults.iloc[i,3])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
353 mr.rep_types = str(mResults.iloc[i,4])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
354 mr.rep_typeAccession = str(mResults.iloc[i,5])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
355 mr.relaxase_type = str(mResults.iloc[i,6])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
356 mr.relaxase_type_accession = str(mResults.iloc[i,7])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
357 mr.mpf_type = str(mResults.iloc[i,8])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
358 mr.mpf_type_accession = str(mResults.iloc[i,9])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
359 mr.orit_type = str(mResults.iloc[i,10])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
360 mr.orit_accession = str(mResults.iloc[i,11])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
361 mr.PredictedMobility = str(mResults.iloc[i,12])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
362 mr.mash_nearest_neighbor = str(mResults.iloc[i,13])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
363 mr.mash_neighbor_distance = float(mResults.iloc[i,14])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
364 mr.mash_neighbor_cluster = int(mResults.iloc[i,15])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
365 mr.row = "\t".join(str(x) for x in mResults.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
366 _mobsuite[mr.file_id] = mr
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
367 return _mobsuite
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
368
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
369 def ParseResFinderResult(pathToResFinderResults, plasmidContigs, likelyPlasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
370 _rFinder = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
371 resFinder = pandas.read_csv(pathToResFinderResults, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
372 resFinder = resFinder.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
373
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
374 for i in range(len(resFinder.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
375 rf = starFinders()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
376 rf.file = str(resFinder.iloc[i,0])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
377 rf.sequence = str(resFinder.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
378 rf.start = int(resFinder.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
379 rf.end = int(resFinder.iloc[i,3])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
380 rf.gene = str(resFinder.iloc[i,4])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
381 rf.shortGene = rf.gene
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
382 rf.coverage = str(resFinder.iloc[i,5])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
383 rf.coverage_map = str(resFinder.iloc[i,6])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
384 rf.gaps = str(resFinder.iloc[i,7])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
385 rf.pCoverage = float(resFinder.iloc[i,8])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
386 rf.pIdentity = float(resFinder.iloc[i,9])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
387 rf.database = str(resFinder.iloc[i,10])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
388 rf.accession = str(resFinder.iloc[i,11])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
389 rf.product = str(resFinder.iloc[i,12])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
390 rf.row = "\t".join(str(x) for x in resFinder.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
391 if (rf.sequence[6:] in plasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
392 rf.source = "plasmid"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
393 elif (rf.sequence[6:] in likelyPlasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
394 rf.source = "likely plasmid"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
395 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
396 rf.source = "likely chromosome"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
397 _rFinder[rf.gene]=rf
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
398 return _rFinder
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
399
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
400 def ParseRGIResult(pathToRGIResults, plasmidContigs, likelyPlasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
401 _rgiR = {}
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
402 RGI = pandas.read_csv(pathToRGIResults, delimiter='\t', header=0)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
403 RGI = RGI.replace(numpy.nan, '', regex=True)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
404
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
405 for i in range(len(RGI.index)):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
406 r = RGIResult()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
407 r.ORF_ID = str(RGI.iloc[i,0])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
408 r.Contig = str(RGI.iloc[i,1])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
409 r.Contig_Num = r.Contig[6:r.Contig.find("_")]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
410 r.Start = int(RGI.iloc[i,2])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
411 r.Stop = int(RGI.iloc[i,3])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
412 r.Orientation = str(RGI.iloc[i,4])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
413 r.Cut_Off = str(RGI.iloc[i,5])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
414 r.Pass_Bitscore = int(RGI.iloc[i,6])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
415 r.Best_Hit_Bitscore = float(RGI.iloc[i,7])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
416 r.Best_Hit_ARO = str(RGI.iloc[i,8])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
417 r.Best_Identities = float(RGI.iloc[i,9])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
418 r.ARO = int(RGI.iloc[i,10])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
419 r.Model_type = str(RGI.iloc[i,11])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
420 r.SNPs_in_Best_Hit_ARO = str(RGI.iloc[i,12])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
421 r.Other_SNPs = str(RGI.iloc[i,13])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
422 r.Drug_Class = str(RGI.iloc[i,14])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
423 r.Resistance_Mechanism = str(RGI.iloc[i,15])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
424 r.AMR_Gene_Family = str(RGI.iloc[i,16])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
425 r.Predicted_DNA = str(RGI.iloc[i,17])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
426 r.Predicted_Protein = str(RGI.iloc[i,18])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
427 r.CARD_Protein_Sequence = str(RGI.iloc[i,19])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
428 r.Percentage_Length_of_Reference_Sequence = float(RGI.iloc[i,20])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
429 r.ID = str(RGI.iloc[i,21])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
430 r.Model_ID = int(RGI.iloc[i,22])
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
431 r.row = "\t".join(str(x) for x in RGI.ix[i].tolist())
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
432 if (r.Contig_Num in plasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
433 r.source = "plasmid"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
434 elif (r.Contig_Num in likelyPlasmidContigs):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
435 r.source = "likely plasmid"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
436 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
437 r.source = "likely chromosome"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
438 _rgiR[r.Model_ID]=r
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
439 return _rgiR
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
440 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
441
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
442 def Main():
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
443 outputDir = "./"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
444 notes = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
445 #init the output list
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
446 output = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
447 jsonOutput = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
448
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
449 print(str(datetime.datetime.now()) + "\n\nID: " + ID + "\nAssembly: " + options.id)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
450 output.append(str(datetime.datetime.now()) + "\n\nID: " + ID + "\nAssembly: " + options.id)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
451
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
452 #region parse the mlst results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
453 print("step 3: parsing mlst, plasmid, and amr results")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
454
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
455 print("identifying MLST")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
456 mlstHit = ParseMLSTResult(mlst, str(mlstScheme))#***********************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
457 ToJson(mlstHit, "mlst.json") #write it to a json output
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
458 mlstHit = list(mlstHit.values())[0]
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
459
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
460 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
461
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
462 #region parse mobsuite, resfinder and rgi results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
463 print("identifying plasmid contigs and amr genes")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
464
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
465 plasmidContigs = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
466 likelyPlasmidContigs = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
467 origins = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
468
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
469 #parse mobsuite results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
470 mSuite = ParseMobsuiteResult(mobfindercontig) #outputDir + "/predictions/" + ID + ".recon/contig_report.txt")#*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
471 ToJson(mSuite, "mobsuite.json") #*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
472 mSuitePlasmids = ParseMobsuitePlasmids(mobfinderaggregate)#outputDir + "/predictions/" + ID + ".recon/mobtyper_aggregate_report.txt")#*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
473 ToJson(mSuitePlasmids, "mobsuitePlasmids.json") #*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
474
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
475 for key in mSuite:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
476 if mSuite[key].contig_num not in plasmidContigs and mSuite[key].contig_num not in likelyPlasmidContigs:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
477 if not (mSuite[key].rep_type == ''):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
478 plasmidContigs.append(mSuite[key].contig_num)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
479 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
480 likelyPlasmidContigs.append(mSuite[key].contig_num)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
481 for key in mSuite:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
482 if mSuite[key].rep_type not in origins:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
483 origins.append(mSuite[key].rep_type)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
484
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
485 #parse resfinder AMR results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
486 rFinder = ParseResFinderResult(abricate, plasmidContigs, likelyPlasmidContigs)#outputDir + "/predictions/" + ID + ".cp", plasmidContigs, likelyPlasmidContigs) #**********************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
487 ToJson(rFinder, "resfinder.json") #*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
488
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
489 rgiAMR = ParseRGIResult(rgi, plasmidContigs, likelyPlasmidContigs) # outputDir + "/predictions/" + ID + ".rgi.txt", plasmidContigs, likelyPlasmidContigs)#***********************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
490 ToJson(rgiAMR, "rgi.json") #*************
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
491
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
492 carbapenamases = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
493 amrGenes = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
494 for keys in rFinder:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
495 carbapenamases.append(rFinder[keys].shortGene + "(" + rFinder[keys].source + ")")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
496 for keys in rgiAMR:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
497 if (rgiAMR[keys].Drug_Class.find("carbapenem") > -1):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
498 if (rgiAMR[keys].Best_Hit_ARO not in carbapenamases):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
499 carbapenamases.append(rgiAMR[keys].Best_Hit_ARO+ "(" + rgiAMR[keys].source + ")")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
500 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
501 if (rgiAMR[keys].Best_Hit_ARO not in amrGenes):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
502 amrGenes.append(rgiAMR[keys].Best_Hit_ARO+ "(" + rgiAMR[keys].source + ")")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
503 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
504
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
505 #region output parsed mlst information
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
506 print("formatting mlst outputs")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
507 output.append("\n\n\n~~~~~~~MLST summary~~~~~~~")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
508 output.append("MLST determined species: " + mlstHit.species)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
509 output.append("\nMLST Details: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
510 output.append(mlstHit.row)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
511
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
512 output.append("\nMLST information: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
513 if (mlstHit.species == expectedSpecies):
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
514 output.append("MLST determined species is the same as expected species")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
515 #notes.append("MLST determined species is the same as expected species")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
516 else:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
517 output.append("!!!MLST determined species is NOT the same as expected species, contamination? mislabeling?")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
518 notes.append("MLST: Not expected species. Possible contamination or mislabeling")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
519
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
520 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
521
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
522 #region output the parsed plasmid/amr results
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
523 output.append("\n\n\n~~~~~~~~Plasmids~~~~~~~~\n")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
524
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
525 output.append("predicted plasmid origins: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
526 output.append(";".join(origins))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
527
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
528 output.append("\ndefinitely plasmid contigs")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
529 output.append(";".join(plasmidContigs))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
530
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
531 output.append("\nlikely plasmid contigs")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
532 output.append(";".join(likelyPlasmidContigs))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
533
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
534 output.append("\nmob-suite prediction details: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
535 for key in mSuite:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
536 output.append(mSuite[key].row)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
537
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
538 output.append("\n\n\n~~~~~~~~AMR Genes~~~~~~~~\n")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
539 output.append("predicted carbapenamase Genes: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
540 output.append(",".join(carbapenamases))
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
541 output.append("other RGI AMR Genes: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
542 for key in rgiAMR:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
543 output.append(rgiAMR[key].Best_Hit_ARO + "(" + rgiAMR[key].source + ")")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
544
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
545 output.append("\nDetails about the carbapenamase Genes: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
546 for key in rFinder:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
547 output.append(rFinder[key].row)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
548 output.append("\nDetails about the RGI AMR Genes: ")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
549 for key in rgiAMR:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
550 output.append(rgiAMR[key].row)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
551
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
552 #write summary to a file
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
553 summaryDir = outputDir + "/summary/" + ID
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
554 out = open("summary.txt", 'w')
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
555 for item in output:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
556 out.write("%s\n" % item)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
557
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
558
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
559 #TSV output
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
560 tsvOut = []
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
561 tsvOut.append("ID\tExpected Species\tMLST Species\tSequence Type\tMLST Scheme\tCarbapenem Resistance Genes\tOther AMR Genes\tTotal Plasmids\tPlasmids ID\tNum_Contigs\tPlasmid Length\tPlasmid RepType\tPlasmid Mobility\tNearest Reference\tDefinitely Plasmid Contigs\tLikely Plasmid Contigs")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
562 #start with ID
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
563 temp = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
564 temp += (ID + "\t")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
565 temp += expectedSpecies + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
566
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
567 #move into MLST
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
568 temp += mlstHit.species + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
569 temp += str(mlstHit.seqType) + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
570 temp += mlstHit.scheme + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
571
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
572 #now onto AMR genes
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
573 temp += ";".join(carbapenamases) + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
574 temp += ";".join(amrGenes) + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
575
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
576 #lastly plasmids
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
577 temp+= str(len(mSuitePlasmids)) + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
578 plasmidID = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
579 contigs = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
580 lengths = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
581 rep_type = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
582 mobility = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
583 neighbour = ""
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
584 for keys in mSuitePlasmids:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
585 plasmidID += str(mSuitePlasmids[keys].mash_neighbor_cluster) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
586 contigs += str(mSuitePlasmids[keys].num_contigs) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
587 lengths += str(mSuitePlasmids[keys].total_length) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
588 rep_type += str(mSuitePlasmids[keys].rep_types) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
589 mobility += str(mSuitePlasmids[keys].PredictedMobility) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
590 neighbour += str(mSuitePlasmids[keys].mash_nearest_neighbor) + ";"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
591 temp += plasmidID + "\t" + contigs + "\t" + lengths + "\t" + rep_type + "\t" + mobility + "\t" + neighbour + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
592 temp += ";".join(plasmidContigs) + "\t"
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
593 temp += ";".join(likelyPlasmidContigs)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
594 tsvOut.append(temp)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
595
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
596 summaryDir = outputDir + "/summary/" + ID
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
597 out = open("summary.tsv", 'w')
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
598 for item in tsvOut:
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
599 out.write("%s\n" % item)
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
600 #endregion
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
601
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
602
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
603 start = time.time()#time the analysis
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
604 print("Starting workflow...")
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
605 #analysis time
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
606 Main()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
607
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
608 end = time.time()
917a05a03ac9 Uploaded
jjjjia
parents:
diff changeset
609 print("Finished!\nThe analysis used: " + str(end-start) + " seconds")