tabtk 1.0.1__tar.gz → 1.0.3__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.
- {tabtk-1.0.1 → tabtk-1.0.3}/PKG-INFO +1 -1
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk/__init__.py +1 -1
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk/tabtk.py +32 -15
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/PKG-INFO +1 -1
- {tabtk-1.0.1 → tabtk-1.0.3}/LICENSE +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/README.md +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/pyproject.toml +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/setup.cfg +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk/__main__.py +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/SOURCES.txt +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/dependency_links.txt +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/entry_points.txt +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/requires.txt +0 -0
- {tabtk-1.0.1 → tabtk-1.0.3}/tabtk.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tabtk
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
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>
|
|
@@ -57,7 +57,7 @@ def pairwiseSimilarity(firstRecord,secondRecord):
|
|
|
57
57
|
return(similarityData)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def alignmentSimilarity(
|
|
60
|
+
def alignmentSimilarity(i,j):
|
|
61
61
|
seqMatch=0
|
|
62
62
|
seqMisMatch=0
|
|
63
63
|
|
|
@@ -89,6 +89,11 @@ def mashSimilarity(cmdValues):
|
|
|
89
89
|
else:
|
|
90
90
|
pass
|
|
91
91
|
|
|
92
|
+
if int(cmdValues["length"])>=16:
|
|
93
|
+
print("Note: use shorter k-mers ≤16 when working diverse sequences")
|
|
94
|
+
else:
|
|
95
|
+
pass
|
|
96
|
+
|
|
92
97
|
tmpOut = f"mash.{str(datetime.datetime.now()).replace(" ","").replace("-",".").replace(":",".")}"
|
|
93
98
|
tmpOutR = f"mash.{str(datetime.datetime.now()).replace(" ","").replace("-",".").replace(":",".")}"
|
|
94
99
|
|
|
@@ -168,7 +173,7 @@ def blastSimilarity(cmdValues):
|
|
|
168
173
|
tmpOut2 = f"blast.{str(datetime.datetime.now()).replace(" ","").replace("-",".").replace(":",".")}"
|
|
169
174
|
|
|
170
175
|
blastCmd1 = f"echo \'qseqid sseqid length pident qcovs\' | tr \' \' \'\\t\' > {tmpOut2}"
|
|
171
|
-
blastCmd2 = f"blastn -db {tmpOut} -query {tmpOut} -num_threads {cmdValues["threads"]} -outfmt \'6 qseqid sseqid length pident qcovs\' -evalue 0.001 >> {tmpOut2}"
|
|
176
|
+
blastCmd2 = f"blastn -db {tmpOut} -query {tmpOut} -word_size {cmdValues["length"]} -num_threads {cmdValues["threads"]} -outfmt \'6 qseqid sseqid length pident qcovs\' -evalue 0.001 >> {tmpOut2}"
|
|
172
177
|
|
|
173
178
|
subprocess.call(blastCmd1,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
|
|
174
179
|
subprocess.call(blastCmd2,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
|
|
@@ -177,7 +182,7 @@ def blastSimilarity(cmdValues):
|
|
|
177
182
|
blastData["tmp"] = blastData.apply(lambda x: (x["qcovs"] * x["pident"])/100,axis=1)
|
|
178
183
|
|
|
179
184
|
blastData["qseqidR"] = blastData.apply(lambda x: x["qseqid"] if x["qseqid"] > x["sseqid"] else x["sseqid"],axis=1)
|
|
180
|
-
blastData["sseqidR"] = blastData.apply(lambda x: x["
|
|
185
|
+
blastData["sseqidR"] = blastData.apply(lambda x: x["sseqid"] if x["qseqid"] > x["sseqid"] else x["qseqid"],axis=1)
|
|
181
186
|
|
|
182
187
|
blastData["qseqid"] = blastData["qseqidR"]
|
|
183
188
|
blastData["sseqid"] = blastData["sseqidR"]
|
|
@@ -225,23 +230,35 @@ def fastaniSimilarity(cmdValues):
|
|
|
225
230
|
else:
|
|
226
231
|
pass
|
|
227
232
|
|
|
233
|
+
if int(cmdValues["length"])>=16:
|
|
234
|
+
print("Note: use shorter k-mers ≤16 when working diverse sequences")
|
|
235
|
+
else:
|
|
236
|
+
pass
|
|
237
|
+
|
|
228
238
|
tmpOut = f"mash.{str(datetime.datetime.now()).replace(" ","").replace("-",".").replace(":",".")}"
|
|
229
239
|
|
|
230
|
-
fastaniCmd = f"fastANI --rl {cmdValues["data"]} --ql {cmdValues["data"]}
|
|
240
|
+
fastaniCmd = f"fastANI --rl {cmdValues["data"]} --ql {cmdValues["data"]} --kmer {cmdValues["length"]} --matrix --fragLen {cmdValues["fragment"]} --minFraction {cmdValues["fraction"]} --output {tmpOut} --threads {cmdValues["threads"]}"
|
|
231
241
|
|
|
232
242
|
print("Calculating percent similarity... may take longer... be patient...")
|
|
233
243
|
|
|
234
244
|
subprocess.call(fastaniCmd,shell=True,stdout=subprocess.DEVNULL,stderr=subprocess.STDOUT)
|
|
235
245
|
|
|
236
246
|
fastaniResults = []
|
|
237
|
-
|
|
247
|
+
|
|
238
248
|
with open(tmpOut,"r") as fastaniFile:
|
|
239
249
|
for itemPos,fastaniOutput in enumerate(fastaniFile):
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
250
|
+
item = fastaniOutput.strip().split("\t")
|
|
251
|
+
fastaniResults.append([Path(item[0]).stem,Path(item[1]).stem,float(item[2])])
|
|
252
|
+
|
|
253
|
+
fastaniData = pd.DataFrame(fastaniResults, columns=["seq1R","seq2R","pidR"])
|
|
254
|
+
fastaniData['pidR'] = fastaniData['pidR'].astype(float)
|
|
255
|
+
|
|
256
|
+
fastaniData["seq1RR"] = fastaniData.apply(lambda x: x["seq1R"] if x["seq1R"] > x["seq2R"] else x["seq2R"],axis=1)
|
|
257
|
+
fastaniData["seq2RR"] = fastaniData.apply(lambda x: x["seq2R"] if x["seq1R"] > x["seq2R"] else x["seq1R"],axis=1)
|
|
258
|
+
|
|
259
|
+
fastaniData = fastaniData[["seq1RR","seq2RR","pidR"]].groupby(['seq1RR','seq2RR']).agg({'pidR':min})
|
|
260
|
+
fastaniDataR = fastaniData.reset_index()
|
|
261
|
+
fastaniDataFinal = fastaniDataR[["seq1RR","seq2RR","pidR"]].rename(columns={"seq1RR":"seq1","seq2RR":"seq2","pid":"pidR"}).values.tolist()
|
|
245
262
|
|
|
246
263
|
if os.path.exists(tmpOut):
|
|
247
264
|
os.remove(tmpOut)
|
|
@@ -253,7 +270,7 @@ def fastaniSimilarity(cmdValues):
|
|
|
253
270
|
else:
|
|
254
271
|
pass
|
|
255
272
|
|
|
256
|
-
return(
|
|
273
|
+
return(fastaniDataFinal)
|
|
257
274
|
|
|
258
275
|
|
|
259
276
|
def similarity(cmdValues):
|
|
@@ -307,7 +324,7 @@ def similarity(cmdValues):
|
|
|
307
324
|
|
|
308
325
|
bar = ChargingBar('Writing similarity values', max=len(similarityResults))
|
|
309
326
|
for itemPair in similarityResults:
|
|
310
|
-
simData.write(f"{itemPair}\n")
|
|
327
|
+
simData.write(f"{"\t".join([str(r) for r in itemPair])}\n")
|
|
311
328
|
|
|
312
329
|
bar.next()
|
|
313
330
|
bar.finish()
|
|
@@ -1210,7 +1227,7 @@ def table(cmdValues):
|
|
|
1210
1227
|
args = [(seqFileNum,seqFileName,kmersFile,cmdValues) for seqFileNum,seqFileName in seqFileDF]
|
|
1211
1228
|
kmerResults = pool.starmap(queryKmers, args)
|
|
1212
1229
|
|
|
1213
|
-
with open(f"{
|
|
1230
|
+
with open(f"{cmdValues["output"]}","w") as kmerData:
|
|
1214
1231
|
kmerFiles = []
|
|
1215
1232
|
kmerHeaderFiles = []
|
|
1216
1233
|
|
|
@@ -1557,8 +1574,8 @@ def tabtkMain():
|
|
|
1557
1574
|
'output': options.output[0:][0] if isinstance(options.output,list) else options.output,
|
|
1558
1575
|
'length': int(options.length[0:][0]) if isinstance(options.length,list) else int(options.length),
|
|
1559
1576
|
'fragment': int(options.fragment[0:][0]) if isinstance(options.fragment,list) else int(options.fragment),
|
|
1560
|
-
'fraction':
|
|
1561
|
-
'size':
|
|
1577
|
+
'fraction': float(options.fraction[0:][0]) if isinstance(options.fraction,list) else float(options.fraction),
|
|
1578
|
+
'size': float(options.size[0:][0]) if isinstance(options.size,list) else float(options.size),
|
|
1562
1579
|
'mash': options.mash,
|
|
1563
1580
|
'fastani': options.fastani,
|
|
1564
1581
|
'blast': options.blast,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tabtk
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|