tabtk 1.0.4__tar.gz → 1.0.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tabtk
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: tabtk: A toolkit for sequence similarity analysis based on tabular data
5
5
  Author-email: Chrispin Chaguza <chrispin.chaguza@gmail.com>
6
6
  Maintainer-email: Chrispin Chaguza <chrispin.chaguza@gmail.com>
@@ -1,4 +1,4 @@
1
1
  """tabkit: A toolkit for sequence similarity analysis based on tabular data"""
2
2
 
3
- __version__ = "1.0.4"
3
+ __version__ = "1.0.6"
4
4
 
@@ -161,10 +161,16 @@ def blastSimilarity(cmdValues):
161
161
 
162
162
  tmpOut = f"blast.{str(datetime.datetime.now()).replace(" ","").replace("-",".").replace(":",".")}"
163
163
 
164
- Cmd1 = f"cat {" ".join(tmpFileNames)} > {tmpOut}"
164
+ bar = ChargingBar("Creating database", max=len(tmpFileNames))
165
+ with open(tmpOut,"w") as tmpOutFile:
166
+ for fileName in tmpFileNames:
167
+ for seq in SeqIO.parse(fileName,"fasta"):
168
+ tmpOutFile.write(f">{seq.id}\n{seq.seq}\n")
169
+ bar.next()
170
+ bar.finish()
171
+
165
172
  Cmd2 = f"makeblastdb -in {tmpOut} -dbtype nucl"
166
173
 
167
- subprocess.call(Cmd1,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
168
174
  subprocess.call(Cmd2,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
169
175
 
170
176
  print("Calculating percent similarity... may take longer... be patient...")
@@ -179,9 +185,11 @@ def blastSimilarity(cmdValues):
179
185
  subprocess.call(blastCmd2,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
180
186
 
181
187
  blastData = pd.read_csv(tmpOut2,delimiter="\t",dtype={'pident': float,'qcovs': float})
182
- blastData["tmp"] = blastData.apply(lambda x: (x["qcovs"] * x["pident"])/100,axis=1)
188
+ blastData["tmp"] = blastData.apply(lambda x: (x["length"] * x["pident"]),axis=1)
189
+
190
+ blastDataR = blastData[["qseqid","sseqid","tmp","length","qcovs"]].groupby(['qseqid','sseqid']).agg({'tmp':'sum','length':'sum'})
191
+ blastData["tmp"] = blastData.apply(lambda x: (((x["tmp"] / x["length"]) * x["qcovs"]) / 100),axis=1)
183
192
 
184
- blastDataR = blastData[["qseqid","sseqid","tmp"]].groupby(['qseqid','sseqid']).agg({'tmp':'mean'})
185
193
  blastDataR = blastDataR.reset_index()
186
194
 
187
195
  blastData["qseqidR"] = blastData.apply(lambda x: x["qseqid"] if x["qseqid"] > x["sseqid"] else x["sseqid"],axis=1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tabtk
3
- Version: 1.0.4
3
+ Version: 1.0.6
4
4
  Summary: tabtk: A toolkit for sequence similarity analysis based on tabular data
5
5
  Author-email: Chrispin Chaguza <chrispin.chaguza@gmail.com>
6
6
  Maintainer-email: Chrispin Chaguza <chrispin.chaguza@gmail.com>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes