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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTFBS
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: PyTFBS: A Python Package for Transcription Factor Binding Site Prediction
5
5
  Author-email: Tinghua Huang <thua45@126.com>
6
6
  License-Expression: MIT
@@ -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) * 5, 1]
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
- data_onehot, poss, j_tmps = seq2onehot(seq, motif_len, motif, seq_freq)
379
- data = torch.tensor(data_onehot)
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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PyTFBS
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: PyTFBS: A Python Package for Transcription Factor Binding Site Prediction
5
5
  Author-email: Tinghua Huang <thua45@126.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PyTFBS"
7
- version = "1.0.4"
7
+ version = "1.0.5"
8
8
  license = "MIT" # SPDX expression
9
9
  description = "PyTFBS: A Python Package for Transcription Factor Binding Site Prediction"
10
10
  readme = "README.md"
File without changes
File without changes
File without changes
File without changes
File without changes