Mercurial > repos > johnheap > vapper
annotate Tryp_V.py @ 7:25226d33642e draft
Uploaded
author | johnheap |
---|---|
date | Mon, 03 Jun 2019 14:06:47 -0400 |
parents | 4432e4183ebd |
children | e75a85590041 |
rev | line source |
---|---|
0
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
1 """ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
2 * Copyright 2018 University of Liverpool |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
3 * Author: John Heap, Computational Biology Facility, UoL |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
4 * Based on original scripts of Sara Silva Pereira, Institute of Infection and Global Health, UoL |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
5 * |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
6 * Licensed under the Apache License, Version 2.0 (the "License"); |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
7 * you may not use this file except in compliance with the License. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
8 * You may obtain a copy of the License at |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
9 * |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
10 * http://www.apache.org/licenses/LICENSE-2.0 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
11 * |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
12 * Unless required by applicable law or agreed to in writing, software |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
13 * distributed under the License is distributed on an "AS IS" BASIS, |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
15 * See the License for the specific language governing permissions and |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
16 * limitations under the License. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
17 * |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
18 """ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
19 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
20 import matplotlib as mpl |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
21 mpl.use('Agg') |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
22 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
23 import subprocess |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
24 import shutil |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
25 import re |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
26 import pandas as pd |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
27 import os |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
28 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
29 import sys |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
30 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
31 import matplotlib.pyplot as plt |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
32 from matplotlib.patches import Patch |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
33 import seaborn as sns |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
34 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
35 def assembleWithVelvet(name, kmers, inslen, covcut, fastq1name,fastq2name): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
36 #argString = "velveth " + name + "_k65 65 -shortPaired -fastq " + name + "_R1.fastq " + name + "_R2.fastq" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
37 argString = "velveth " + name + "_k"+ kmers+" "+ kmers + " -shortPaired -fastq " + fastq1name+" "+fastq2name |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
38 print(argString) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
39 returncode = subprocess.call(argString, shell=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
40 if returncode != 0: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
41 return "Error in velveth" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
42 argString = "velvetg " + name + "_k"+kmers+" -exp_cov auto -ins_length "+inslen+" -clean yes -ins_length_sd 50 -min_pair_count 20" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
43 #argString = "velvetg " + name + "_k"+kmers+" -exp_cov auto -ins_length "+inslen+" -cov_cutoff "+covcut+" -clean yes -ins_length_sd 50 -min_pair_count 20" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
44 #argString = "velvetg " + name + "_k65 -exp_cov auto -ins_length 400 -cov_cutoff 5 -clean yes -ins_length_sd 50 -min_pair_count 20"+quietString |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
45 print(argString) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
46 returncode = subprocess.call(argString, shell = True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
47 if returncode != 0: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
48 return "Error in velvetg" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
49 shutil.copyfile(name + "_k"+kmers+"//contigs.fa",name + ".fa") # my $namechange = "mv ".$input."_k65/contigs.fa ".$input.".fa"; |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
50 return "ok" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
51 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
52 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
53 def blastContigs(test_name,database): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
54 print(test_name) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
55 print(database) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
56 #db_path = os.path.dirname(os.path.realpath(__file__))+database |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
57 db_path = database |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
58 argString = "blastn -db "+db_path+" -query "+test_name+".fa -outfmt 10 -out "+test_name+"_blast.txt" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
59 print (argString) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
60 returncode = subprocess.call(argString, shell = True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
61 if returncode != 0: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
62 return "Error in blastall" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
63 blast_df = pd.read_csv(""+test_name+"_blast.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
64 #print (blast_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
65 #if ($temp[2] >= 98 & & $temp[3] > 100 & & $temp[10] < 0.001){ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
66 #'qaccver saccver pident length mismatch gapopen qstart qend sstart send evalue bitscore' |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
67 blast_df.columns = ['qaccver', 'saccver', 'pident', 'length', 'mismatch', 'gapopen', 'qstart', 'qend', 'sstart', 'send', 'evalue','bitscore'] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
68 blastResult_df = blast_df[(blast_df['pident']>=98) & (blast_df['length'] > 100) & (blast_df['evalue']<0.001) ] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
69 blastResult_df = blastResult_df[['qaccver', 'saccver', 'pident']] #query accession.version, subject accession.version, Percentage of identical matches |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
70 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
71 return blastResult_df |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
72 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
73 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
74 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
75 def getCogsPresent(blastResult_df,strain,cogOrBinList): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
76 blastResult_df.sort_values('pident',axis = 0, ascending=False, inplace=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
77 nodeList = blastResult_df['qaccver'].tolist() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
78 cogList = blastResult_df['saccver'].tolist() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
79 cogSet = set(cogList) #get unique values |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
80 cogList = sorted(cogSet) #sort them |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
81 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
82 #print (cogList) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
83 #print (len(cogList)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
84 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
85 thereList = [] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
86 dataList = [] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
87 #dir_path = os.path.dirname(os.path.realpath(__file__)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
88 fname = cogOrBinList |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
89 cnt = 0 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
90 with open (fname) as f: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
91 for line in f: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
92 dataList.append(line.rstrip('\n\r ')) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
93 if line.rstrip('\n\r ') in cogList: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
94 thereList.append('1') |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
95 cnt = cnt+1 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
96 else: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
97 thereList.append('0') |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
98 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
99 #print (thereList) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
100 #print (cnt) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
101 data = {'Cog': dataList, strain: thereList} |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
102 presence_df = pd.DataFrame(data) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
103 #print (presence_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
104 return presence_df |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
105 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
106 def addToCurrentData(cog_df, name): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
107 dir_path = os.path.dirname(os.path.realpath(__file__)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
108 j_fname = dir_path + r"/data/vivax/TvDatabase.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
109 tv_df = pd.read_csv(j_fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
110 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
111 cogList = cog_df[name].tolist() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
112 #cogList.insert(0,'Test') |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
113 #print (len(tv_df)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
114 #print(len(cogList)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
115 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
116 #print(cogList) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
117 tv_df.loc[:,name]=cogList |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
118 return tv_df |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
119 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
120 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
121 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
122 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
123 def createClusterMap(tv_df,name,html_path,pdfExport): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
124 #Retrieve Data |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
125 dir_path = os.path.dirname(os.path.realpath(__file__)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
126 j_fname = dir_path+r"/data/vivax/geoTv.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
127 geo_df = pd.read_csv(j_fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
128 geo_df.loc[len(geo_df)] =[name,name,'k'] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
129 print(geo_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
130 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
131 myStrains = tv_df.columns.values.tolist() #beware first entry is COG |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
132 myStrains = myStrains[1:] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
133 print(myStrains) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
134 myPal = [] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
135 for s in myStrains: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
136 col = geo_df[(geo_df['Strain'] == s)]['colour'].tolist() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
137 myPal.append(col[0]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
138 print(myPal) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
139 mycogmap = ['skyblue', 'orangered'] # blue absent,red present |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
140 tv_df.set_index('COG', inplace=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
141 tv_df = tv_df[tv_df.columns].astype(float) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
142 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
143 cg = sns.clustermap(tv_df, method='ward', col_colors=myPal, cmap=mycogmap, yticklabels = 1500, row_cluster=False, linewidths = 0) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
144 #cg = sns.clustermap(tv_df, method='ward', row_cluster=False, linewidths = 0) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
145 ax = cg.ax_heatmap |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
146 #xasix ticks and labels. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
147 ax.xaxis.tick_top() #set ticks at top |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
148 newlabs = [] |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
149 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
150 labs = ax.xaxis.get_ticklabels() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
151 for i in range(0, len(labs)): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
152 print(labs[i]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
153 # labs[i].set_text(" "+labs[i].get_text()) #make enough room so label sits atop of col_color bars |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
154 newlabs.append(" " + labs[i].get_text()) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
155 ax.xaxis.set_ticklabels(newlabs) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
156 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
157 #labs = ax.xaxis.get_ticklabels() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
158 #for i in range(0, len(labs)): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
159 # print(labs[i]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
160 # labs[i].set_text(" "+labs[i].get_text()) #make enough room so label sits atop of col_color bars |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
161 # print(labs[i]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
162 #ax.xaxis.set_ticklabels(labs) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
163 plt.setp(cg.ax_heatmap.xaxis.get_ticklabels(), rotation=90) # get x labels printed vertically |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
164 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
165 cg.cax.set_visible(False) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
166 ax = cg.ax_heatmap |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
167 ax.set_yticklabels("") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
168 ax.set_ylabel("") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
169 ax = cg.ax_heatmap |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
170 # ax.set_title("Variant antigen profiles of T. vivax genomes.\nDendrogram reflects the VSG repertoire relationships of each strain inferred by the presence and absence of non-universal T. vivax VSG orthologs.", va = "top", wrap = "True") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
171 b = len(tv_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
172 print(b) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
173 title = "Figure Legend: The Variant Antigen Profiles of $\itTrypanosoma$ $\itvivax$ " \ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
174 "showing the \ncombination of present and absent diagnostic cluster of VSG orthologs " \ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
175 "across the sample cohort. \nDendrogram reflects the relationships amongst the VSG" \ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
176 " repertoires of each strain. " \ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
177 "Strains were isolated \nfrom multiple African countries as shown in the key.\nData was produced with the " \ |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
178 "'Variant Antigen Profiler' (Silva Pereira and Jackson, 2018)." |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
179 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
180 ax.text(-1.5, len(tv_df) + 8, |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
181 title, |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
182 ha="left", va="top", wrap="True") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
183 col = cg.ax_col_dendrogram.get_position() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
184 cg.ax_col_dendrogram.set_position([col.x0, col.y0*1.08, col.width, col.height*1.1]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
185 |
3
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
186 countryList = pd.unique(geo_df['Location']) |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
187 colourList = pd.unique(geo_df['colour']) |
0
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
188 legend_elements = [Patch(facecolor='orangered', label='COG Present'), |
3
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
189 Patch(facecolor='skyblue', label='COG Absent')] |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
190 |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
191 for i in range(0, len(colourList)): |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
192 print("country = %s, colour = %s" % (countryList[i], colourList[i])) |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
193 p = Patch(facecolor=str(colourList[i]), label=countryList[i]) |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
194 legend_elements.append(p) |
4432e4183ebd
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
0
diff
changeset
|
195 |
0
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
196 ax.legend(handles = legend_elements, bbox_to_anchor=(-0.3,1.2),loc = 'upper left') |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
197 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
198 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
199 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
200 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
201 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
202 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
203 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
204 #plt.setp(cg.ax_heatmap.yaxis.get_ticklabels(), rotation=0 ) # get y labels printed horizontally |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
205 # cg.dendrogram_col.linkage # linkage matrix for columns |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
206 # cg.dendrogram_row.linkage # linkage matrix for rows |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
207 # plt.savefig(r"results/" + name + "_heatmap.png") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
208 #plt.savefig(htmlresource + "/heatmap.png") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
209 #if pdf == 'PDF_Yes': |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
210 # plt.savefig(htmlresource + "/heatmap.pdf") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
211 # shutil.copyfile("heatmap.pdf",heatmapfn) # |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
212 #plt.legend() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
213 fname = html_path+"/"+name+"_clustermap.png" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
214 cg.savefig(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
215 if pdfExport == 'PDF_Yes': |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
216 fname = html_path + "/" + name + "_clustermap.pdf" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
217 cg.savefig(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
218 #plt.show() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
219 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
220 def createHTML(name,htmlfn,htmlPath): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
221 #assumes imgs are heatmap.png, dheatmap.png, vapPCA.png and already in htmlresource |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
222 htmlString = r"<html><title>T.vivax VAP</title><body><div style='text-align:center'><h2><i>Trypanosoma vivax</i> Variant Antigen Profile</h2><h3>" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
223 htmlString += name |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
224 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
225 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
226 htmlString += r'<p> <h3>The Heat Map and Dendrogram</h3></p>' |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
227 imgString = r"<img src = '"+name+"_clustermap.png' alt='Cog Clustermap' style='max-width:100%'><br><br>" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
228 htmlString += imgString |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
229 print(htmlString) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
230 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
231 with open(htmlfn, "w") as htmlfile: |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
232 htmlfile.write(htmlString) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
233 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
234 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
235 def vivax_assemble(args,dict): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
236 #argdict = {'name': 2, 'pdfexport': 3, 'kmers': 4, 'inslen': 5, 'covcut': 6, 'forward': 7, 'reverse': 8, 'html_file': 9,'html_resource': 10} |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
237 #assembleWithVelvet("V2_Test", '65', '400', '5', "data/TviBrRp.1.clean", "data/TviBrRp.2.clean") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
238 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
239 vivaxPath = os.path.dirname(os.path.realpath(__file__))+r"/data/vivax" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
240 assembleWithVelvet(args[dict['name']], args[dict['kmers']], args[dict['inslen']], args[dict['covcut']], |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
241 args[dict['forward']], args[dict['reverse']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
242 blastResult_df = blastContigs(args[dict['name']], vivaxPath+r"/Database/COGs.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
243 orthPresence_df = getCogsPresent(blastResult_df, args[dict['name']], vivaxPath+r"/Database/COGlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
244 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
245 binBlastResult_df = blastContigs(args[dict['name']], vivaxPath+r"/Database/Bin_2.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
246 binPresence_df = getCogsPresent(binBlastResult_df, args[dict['name']], vivaxPath+r"/Database/binlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
247 cogPresence_df = orthPresence_df.append(binPresence_df, ignore_index=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
248 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
249 fname = args[dict['html_resource']] +args[dict['name']]+"_cogspresent.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
250 cogPresence_df.to_csv(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
251 current_df = addToCurrentData(cogPresence_df,args[dict['name']]) # load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
252 createClusterMap(current_df, args[dict['name']],args[dict['html_resource']],args[dict['pdfexport']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
253 createHTML(args[dict['name']],args[dict['html_file']],args[dict['html_resource']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
254 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
255 def test_cluster(args,dict): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
256 print ("name: %s",args[dict['name']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
257 cogPresence_df = pd.read_csv("test_cogspresent.csv") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
258 print(cogPresence_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
259 current_df = addToCurrentData(cogPresence_df,args[dict['name']]) # load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
260 createClusterMap(current_df, args[dict['name']], args[dict['html_resource']], args[dict['pdfexport']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
261 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
262 def vivax_contigs(args,dict): |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
263 # argdict = {'name': 2, 'pdfexport': 3, 'contigs': 4, 'html_file': 5, 'html_resource': 6} |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
264 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
265 #test_cluster(args,dict) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
266 #return; |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
267 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
268 #subprocess.call('echo $PATH',shell = True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
269 #sys.exit(1) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
270 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
271 vivaxPath = os.path.dirname(os.path.realpath(__file__))+r"/data/vivax" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
272 shutil.copyfile(args[dict['contigs']], args[dict['name']]+".fa") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
273 blastResult_df = blastContigs(args[dict['name']], vivaxPath+r"/Database/COGs.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
274 orthPresence_df = getCogsPresent(blastResult_df, args[dict['name']], vivaxPath+r"/Database/COGlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
275 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
276 binBlastResult_df = blastContigs(args[dict['name']], vivaxPath+r"/Database/Bin_2.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
277 binPresence_df = getCogsPresent(binBlastResult_df, args[dict['name']], vivaxPath+r"/Database/binlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
278 cogPresence_df = orthPresence_df.append(binPresence_df, ignore_index=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
279 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
280 fname = args[dict['html_resource']]+r"/"+ args[dict['name']]+"_cogspresent.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
281 cogPresence_df.to_csv(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
282 current_df = addToCurrentData(cogPresence_df,args[dict['name']]) # load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
283 createClusterMap(current_df, args[dict['name']], args[dict['html_resource']], args[dict['pdfexport']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
284 createHTML(args[dict['name']],args[dict['html_file']],args[dict['html_resource']]) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
285 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
286 if __name__ == "__main__": |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
287 #assembleWithVelvet("V2_Test",'65','400', '5',"data/TviBrRp.1.clean","data/TviBrRp.2.clean") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
288 #assembleWithVelvet("V2_Test",'65','400', '5',"data/Tv493.1","data/Tv493.2") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
289 #blastResult_df=blastContigs("V2_Test",r"/Database/COGs.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
290 cogPresence_df = pd.read_csv("test_cogspresent.csv") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
291 print(cogPresence_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
292 current_df = addToCurrentData(cogPresence_df,"vTest") # load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
293 createClusterMap(current_df, "vTest", "sausages","no") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
294 createHTML("vTest","vTest.html","sausages") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
295 sys.exit() |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
296 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
297 blastResult_df=blastContigs("Tv493",r"/Database/COGs.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
298 orthPresence_df = getCogsPresent(blastResult_df,"Tv493",r"/Database/COGlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
299 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
300 #binBlastResult_df=blastContigs("V2_Test",r"/Database/Bin_2.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
301 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
302 binBlastResult_df=blastContigs("Tv493",r"/Database/Bin_2.fas") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
303 binPresence_df = getCogsPresent(binBlastResult_df,"Tv493",r"/Database/binlist.txt") |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
304 cogPresence_df = orthPresence_df.append(binPresence_df, ignore_index=True) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
305 #now do the next bit? |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
306 current_df = addToCurrentData(cogPresence_df) # load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
307 createClusterMap(current_df,'Test',dict['html_resource'] ,dict['pdfexport']) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
308 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
309 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
310 #print(cogPresence_df) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
311 dir_path = os.path.dirname(os.path.realpath(__file__)) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
312 fname = dir_path+r"/results/V2_TestPresence.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
313 #fnameb = dir_path+r"/results/V2_Test_blastOrth.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
314 #fnameb_bin = dir_path+r"/results/V2_Test_blastBin.csv" |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
315 #binBlastResult_df.to_csv(fnameb_bin) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
316 #blastResult_df.to_csv(fnameb) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
317 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
318 #cogPresence_df.to_csv(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
319 cogPresence_df = pd.read_csv(fname) |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
320 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
321 current_df = addToCurrentData(cogPresence_df) #load in Tvdatabase and add cogPresence column to it. |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
322 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
323 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
324 |
36cb22bd911d
planemo upload for repository https://github.com/johnheap/VAPPER-Galaxy
johnheap
parents:
diff
changeset
|
325 |