PyTFBS 1.0.4__tar.gz → 1.0.5__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.
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PKG-INFO +1 -1
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS/predict.py +28 -3
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/PKG-INFO +1 -1
- {pytfbs-1.0.4 → pytfbs-1.0.5}/pyproject.toml +1 -1
- {pytfbs-1.0.4 → pytfbs-1.0.5}/LICENSE +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS/__init__.py +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS/motif.py +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/SOURCES.txt +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/dependency_links.txt +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/entry_points.txt +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/requires.txt +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/PyTFBS.egg-info/top_level.txt +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/README.md +0 -0
- {pytfbs-1.0.4 → pytfbs-1.0.5}/setup.cfg +0 -0
|
@@ -232,6 +232,31 @@ def predict_seq():
|
|
|
232
232
|
motif = motifs_all[motif_name][0]
|
|
233
233
|
predict_llrs(seq, motif, seq_name, motif_name)
|
|
234
234
|
|
|
235
|
+
def seq2llr(seq_in, motif_len, motif, base_freq):
|
|
236
|
+
poss = []
|
|
237
|
+
j_tmps = []
|
|
238
|
+
llr_matrix = []
|
|
239
|
+
seq_len = len(seq_in)
|
|
240
|
+
dseq = sequence_to_numbers(seq_in)
|
|
241
|
+
for si in range(seq_len - motif_len + 1):
|
|
242
|
+
llr_sum = 0.0
|
|
243
|
+
llrs = []
|
|
244
|
+
for mi in range(motif_len):
|
|
245
|
+
base = dseq[si + mi]
|
|
246
|
+
if base == 4:
|
|
247
|
+
llr = 0.0
|
|
248
|
+
else:
|
|
249
|
+
llr = math.log(motif[mi][base] / base_freq[base]);
|
|
250
|
+
llr_sum += llr
|
|
251
|
+
# print(motif[mi][base], base_freq[base])
|
|
252
|
+
llrs.append(llr)
|
|
253
|
+
j_tmp = llr_sum / motif_len
|
|
254
|
+
if j_tmp > 0.0:
|
|
255
|
+
llr_matrix.append(llrs)
|
|
256
|
+
j_tmps.append(j_tmp)
|
|
257
|
+
poss.append(si)
|
|
258
|
+
return llr_matrix, poss, j_tmps
|
|
259
|
+
|
|
235
260
|
def seq2onehot(seq_in, motif_len, motif, base_freq):
|
|
236
261
|
datas = []
|
|
237
262
|
poss = []
|
|
@@ -361,7 +386,7 @@ def script(motif_id, model_id, seq_file, out_file, data_dir=None):
|
|
|
361
386
|
print(seq_file, 'not exist!')
|
|
362
387
|
exit(1)
|
|
363
388
|
motif_name, motif = read_motif_single(motif_file)
|
|
364
|
-
data_dim = [len(motif)
|
|
389
|
+
data_dim = [len(motif), 1]
|
|
365
390
|
#model = loade_model_pars(model_file, data_dim)
|
|
366
391
|
model = loade_model_trace(model_file)
|
|
367
392
|
# run predict
|
|
@@ -375,8 +400,8 @@ def script(motif_id, model_id, seq_file, out_file, data_dir=None):
|
|
|
375
400
|
seq = fasta[seq_name].upper()
|
|
376
401
|
if has_non_acgtn_upper(seq):
|
|
377
402
|
continue
|
|
378
|
-
|
|
379
|
-
data = torch.tensor(
|
|
403
|
+
data_llr, poss, j_tmps = seq2llr(seq, motif_len, motif, seq_freq)
|
|
404
|
+
data = torch.tensor(data_llr)
|
|
380
405
|
data = data.view(-1, data_dim[0])
|
|
381
406
|
logits = model(data).flatten().tolist()
|
|
382
407
|
#indices = torch.nonzero(logits > 0.5, as_tuple=False).squeeze().tolist()
|
|
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
|