Mercurial > repos > johnheap > vapper
comparison Tryp_V_T.py @ 25:c0a6a170163e draft
Uploaded
author | johnheap |
---|---|
date | Tue, 04 Jun 2019 18:11:54 -0400 |
parents | 1b5bf8383973 |
children | 7983a9305b53 |
comparison
equal
deleted
inserted
replaced
24:728b1d375b41 | 25:c0a6a170163e |
---|---|
118 | 118 |
119 pass | 119 pass |
120 | 120 |
121 def blastContigs(test_name,html_resource, database): | 121 def blastContigs(test_name,html_resource, database): |
122 db_path = database | 122 db_path = database |
123 argString = "blastx -db "+db_path+" -query "+test_name+"_for_blast.fa -outfmt 10 -out "+test_name+"_blast.txt" | 123 #argString = "makeblastdb - in " + db_path |
124 #subprocess.call(argString, shell=True) | |
125 | |
126 argString = "blastx -db " + db_path + " -query "+test_name+"_for_blast.fa -outfmt 10 -out "+test_name+"_blast.txt" | |
124 print(argString) | 127 print(argString) |
125 returncode = subprocess.call(argString, shell=True) | 128 returncode = subprocess.call(argString, shell=True) |
126 if returncode != 0: | 129 if returncode != 0: |
127 return "Error in blastall" | 130 return "Error in blastall" |
128 blast_df = pd.read_csv(""+test_name+"_blast.txt") | 131 blast_df = pd.read_csv(""+test_name+"_blast.txt") |
222 htmlString += tabString + "</table><br><br><br><br><br>" | 225 htmlString += tabString + "</table><br><br><br><br><br>" |
223 htmlString += r"<h3>Weighted Relative Frequencies of Detected Phylotypes.</h3>" | 226 htmlString += r"<h3>Weighted Relative Frequencies of Detected Phylotypes.</h3>" |
224 imgString = r"<img src = '"+ tdict['name']+"_phylotypes.png' alt='Bar chart of phylotype variation' style='max-width:100%'><br><br>" | 227 imgString = r"<img src = '"+ tdict['name']+"_phylotypes.png' alt='Bar chart of phylotype variation' style='max-width:100%'><br><br>" |
225 htmlString += imgString | 228 htmlString += imgString |
226 | 229 |
227 with open(tdict['html_file'], "w") as htmlfile: | 230 with open(tdict['html_resource']+'/'+tdict['html_file'], "w") as htmlfile: |
228 htmlfile.write(htmlString) | 231 htmlfile.write(htmlString) |
229 | 232 |
230 | 233 |
231 | 234 |
232 def getPhyloNumber(sac): | 235 def getPhyloNumber(sac): |
234 return int(sac[1:i]) | 237 return int(sac[1:i]) |
235 | 238 |
236 def combineFPMK(tdict): | 239 def combineFPMK(tdict): |
237 dir_path = os.path.dirname(os.path.realpath(__file__))+'/' | 240 dir_path = os.path.dirname(os.path.realpath(__file__))+'/' |
238 | 241 |
239 fpkm_df = pd.read_csv(dir_path++tdict['name']+'.cuff/genes.fpkm_tracking', sep='\t') | 242 fpkm_df = pd.read_csv(dir_path+tdict['name']+'.cuff/genes.fpkm_tracking', sep='\t') |
240 | 243 |
241 #fpkm_df = pd.read_csv('genes.fpkm_tracking',sep='\t') | 244 #fpkm_df = pd.read_csv('genes.fpkm_tracking',sep='\t') |
242 #print(fpkm_df.head()) | 245 #print(fpkm_df.head()) |
243 fpkm_df['locus'] = fpkm_df['locus'].apply(lambda names: names[:names.find(':')]) | 246 fpkm_df['locus'] = fpkm_df['locus'].apply(lambda names: names[:names.find(':')]) |
244 #print(fpkm_df.head()) | 247 #print(fpkm_df.head()) |
390 # plt.text(-0.3, -0.15, title, va="top", wrap="True") | 393 # plt.text(-0.3, -0.15, title, va="top", wrap="True") |
391 #plt.tight_layout() | 394 #plt.tight_layout() |
392 plt.subplots_adjust(bottom=0.1, top=0.9, left=0.15, right=0.9) | 395 plt.subplots_adjust(bottom=0.1, top=0.9, left=0.15, right=0.9) |
393 ax.set_title(title, x=0, wrap='True',ha='left',) | 396 ax.set_title(title, x=0, wrap='True',ha='left',) |
394 | 397 |
395 plt.savefig(tdict['html_resource'] + tdict['name']+"_phylotypes.png") | 398 plt.savefig(tdict['html_resource'] + '/' + tdict['name']+"_phylotypes.png") |
396 if tdict['pdf'] == 'PDF_Yes': | 399 if tdict['pdf'] == 'PDF_Yes': |
397 plt.savefig(tdict['html_resource'] + tdict['name']+"phylotypes.pdf") | 400 plt.savefig(tdict['html_resource'] + '/' + tdict['name']+"phylotypes.pdf") |
398 # plt.show() | 401 # plt.show() |
399 pass | 402 pass |
400 | 403 |
401 # argdict = {'name':2, 'pdfexport': 3, 'refFastq': 4, 'forward': 5, 'reverse': 6, 'html_file': 7, 'html_resource': 8} | 404 # argdict = {'name':2, 'pdfexport': 3, 'refFastq': 4, 'forward': 5, 'reverse': 6, 'html_file': 7, 'html_resource': 8} |
402 | 405 |