How to use seq method in fMBT

Best Python code snippet using fMBT_python

DatasetTest.py

Source:DatasetTest.py Github

copy

Full Screen

1from torch.utils.data import Dataset2import numpy as np3import os4class DatasetTest(Dataset):5 def __init__(self, dataset_path, action_type, postex, global_max, global_min):6 super(DatasetTest, self).__init__()7 self.dataset_path = dataset_path + action_type + postex8 self.seq_45 = np.load(self.dataset_path)9 self.seq_45 = np.transpose(self.seq_45, (0, 2, 1))10 11 self.global_max = global_max12 self.global_min = global_min13 # Normalize14 self.seq_45 = (self.seq_45 - self.global_min) / (self.global_max - self.global_min)15 self.seq_45 = self.seq_45 * 2 - 116 # self.seq_pre_10 = self.seq_45[:, :10, :]17 # self.seq_mid_25 = self.seq_45[:, 10:35, :]18 # self.seq_post_10 = self.seq_45[:, 35:, :]19 # self.seq_pre_10 = self.seq_45[:, 9:10, :]20 # self.seq_mid_25 = self.seq_45[:, 10:35, :]21 # self.seq_post_10 = self.seq_45[:, 35:36, :]22 # self.seq_pre_10 = self.seq_45[:, 5:10, :]23 # self.seq_mid_25 = self.seq_45[:, 10:35, :]24 # self.seq_post_10 = self.seq_45[:, 35:40, :]25 # last_x = self.seq_45[:, 9, :]26 # first_z = self.seq_45[:, 35, :]27 #5_25_528 # self.seq_pre_10 = self.seq_45[:, :5, :]29 # self.seq_mid_25 = self.seq_45[:, 5:30, :]30 # self.seq_post_10 = self.seq_45[:, 30:, :]31 # last_x = self.seq_45[:, 4, :]32 # first_z = self.seq_45[:, 30, :]33 #10_25_1034 # self.seq_pre_10 = self.seq_45[:, :10, :]35 # self.seq_mid_25 = self.seq_45[:, 10:35, :]36 # self.seq_post_10 = self.seq_45[:, 35:, :]37 # last_x = self.seq_45[:, 9, :]38 # first_z = self.seq_45[:, 35, :]39 #15_25_1040 # self.seq_pre_10 = self.seq_45[:, :15, :]41 # self.seq_mid_25 = self.seq_45[:, 15:40, :]42 # self.seq_post_10 = self.seq_45[:, 40:, :]43 # last_x = self.seq_45[:, 14, :]44 # first_z = self.seq_45[:, 40, :]45 #20_25_2046 # self.seq_pre_10 = self.seq_45[:, :20, :]47 # self.seq_mid_25 = self.seq_45[:, 20:45, :]48 # self.seq_post_10 = self.seq_45[:, 45:, :]49 # last_x = self.seq_45[:, 19, :]50 # first_z = self.seq_45[:, 45, :]51 # print(self.seq_45.shape)52 self.seq_pre_10 = self.seq_45[:, 10:20, :]53 self.seq_mid_25 = self.seq_45[:, 20:45, :]54 self.seq_post_10 = self.seq_45[:, 45:55, :]55 last_x = self.seq_45[:, 19, :]56 first_z = self.seq_45[:, 45, :]57 self.mid_resid = np.linspace(last_x, first_z, 25).transpose((1, 0, 2))58 # self.mid_repx = np.repeat(self.seq_45[:, 9:10, :], (1, 25, 1))59 # self.mid_repz = np.repeat(self.seq_45[:, 35:36, :], (1, 25, 1))60 # self.seq_pre_10 = self.seq_pre_10[:48]61 # self.seq_mid_25 = self.seq_mid_25[:48]62 # self.mid_resid = self.mid_resid[:48]63 # self.seq_post_10 = self.seq_post_10[:48]64 self.data_num = len(self.seq_pre_10)65 def __len__(self):66 return self.data_num67 def __getitem__(self, item):68 output = {69 'pre_10': self.seq_pre_10[item],70 'mid_25': self.seq_mid_25[item],71 'mid_resid': self.mid_resid[item],72 'post_10': self.seq_post_10[item],73 # 'mid_repx':self.mid_repx[item],74 # 'mid_repz': self.mid_repz[item]75 }...

Full Screen

Full Screen

DatasetTrain.py

Source:DatasetTrain.py Github

copy

Full Screen

1from torch.utils.data import Dataset2import numpy as np3import os4class DatasetTrain(Dataset):5 def __init__(self, dataset_path, mode_name, global_max=1e20, global_min=-1e20):6 super(DatasetTrain, self).__init__()7 self.dataset_path = dataset_path8 self.seq_45 = np.load(dataset_path)9 10 if mode_name == 'train':11 self.global_max = np.max(self.seq_45)12 self.global_min = np.min(self.seq_45)13 else:14 self.global_max = global_max15 self.global_min = global_min16 # Normalize17 self.seq_45 = (self.seq_45 - self.global_min) / (self.global_max - self.global_min)18 self.seq_45 = self.seq_45 * 2 - 119 ma = np.max(self.seq_45)20 mb = np.min(self.seq_45)21 # self.seq_pre_10 = self.seq_45[:, :10, :]22 # self.seq_mid_25 = self.seq_45[:, 10:35, :]23 # self.seq_post_10 = self.seq_45[:, 35:, :]24 # self.seq_pre_10 = self.seq_45[:, 9:10, :]25 # self.seq_mid_25 = self.seq_45[:, 10:35, :]26 # self.seq_post_10 = self.seq_45[:, 35:36, :]27 # self.seq_pre_10 = self.seq_45[:, 5:10, :]28 # self.seq_mid_25 = self.seq_45[:, 10:35, :]29 # self.seq_post_10 = self.seq_45[:, 35:40, :]30 # last_x = self.seq_45[:, 9, :]31 # first_z = self.seq_45[:, 35, :]32 #5_25_533 # self.seq_pre_10 = self.seq_45[:, :5, :]34 # self.seq_mid_25 = self.seq_45[:, 5:30, :]35 # self.seq_post_10 = self.seq_45[:, 30:, :]36 # last_x = self.seq_45[:, 4, :]37 # first_z = self.seq_45[:, 30, :]38 #10_25_1039 # self.seq_pre_10 = self.seq_45[:, :10, :]40 # self.seq_mid_25 = self.seq_45[:, 10:35, :]41 # self.seq_post_10 = self.seq_45[:, 35:, :]42 # last_x = self.seq_45[:, 9, :]43 # first_z = self.seq_45[:, 35, :]44 #15_25_1545 # self.seq_pre_10 = self.seq_45[:, :15, :]46 # self.seq_mid_25 = self.seq_45[:, 15:40, :]47 # self.seq_post_10 = self.seq_45[:, 40:, :]48 # last_x = self.seq_45[:, 14, :]49 # first_z = self.seq_45[:, 40, :]50 #20_25_2051 # self.seq_pre_10 = self.seq_45[:, :20, :]52 # self.seq_mid_25 = self.seq_45[:, 20:45, :]53 # self.seq_post_10 = self.seq_45[:, 45:, :]54 # last_x = self.seq_45[:, 19, :]55 # first_z = self.seq_45[:, 45, :]56 self.seq_pre_10 = self.seq_45[:, 10:20, :]57 self.seq_mid_25 = self.seq_45[:, 20:45, :]58 self.seq_post_10 = self.seq_45[:, 45:55, :]59 last_x = self.seq_45[:, 19, :]60 first_z = self.seq_45[:, 45, :]61 self.mid_resid = np.linspace(last_x, first_z, 25).transpose((1, 0, 2))62 # self.mid_resid = np.repeat(self.seq_45[:, 9:10, :], (1, 25, 1))63 self.data_num = len(self.seq_post_10)64 def __len__(self):65 return self.data_num66 def __getitem__(self, item):67 output = {68 'pre_10': self.seq_pre_10[item],69 'mid_25': self.seq_mid_25[item],70 'mid_resid': self.mid_resid[item],71 'post_10': self.seq_post_10[item]72 }...

Full Screen

Full Screen

strand-guess.py

Source:strand-guess.py Github

copy

Full Screen

1#! /usr/bin/env python32def strand_guess(aligner, q, t, minpct=50):3 """Guess the strand of t (target) that q (query) lies on.4 Given a Bio.Align aligner and two Bio.SeqRecords q and t, guess which strand5 of t that q lies on. The approach is to align both q and q.reverse_complement()6 to t, seeing which scores higher. The score has to be at least minpct of the7 maximum possible score, default 50 percent.8 ARGUMENTS9 aligner: A Bio.Align aligner.10 q: Query sequence as a Bio.SeqRecord.11 t: Target sequence as a Bio.SeqRecord.12 minpct: Score of best alignment between q and t must be at least minpct13 percent of the maximum possible score.14 RETURNS15 > 0: q appears to lie on the forward strand of t.16 < 0: q appears to lie on the reverse strand of t.17 otherwise: unable to determine which strand of t.18 """19 score_max = min(aligner.score(t.seq, t.seq), aligner.score(q.seq, q.seq))20 score_f = aligner.score(q.seq, t.seq)21 score_r = aligner.score(q.reverse_complement().seq, t.seq)22 if score_f > score_r and score_f >= minpct * score_max / 100:23 return 124 elif score_r > score_f and score_r >= minpct * score_max / 100:25 return -126 else:27 return 028if __name__ == "__main__":29 # Do a few checks30 from Bio import Align31 from Bio.Seq import Seq32 from Bio.SeqRecord import SeqRecord33 aligner = Align.PairwiseAligner()34 aligner.mode = "global"35 # x aligns with the forward strand of y with a small insertion36 x = SeqRecord(37 Seq("CATCAAGCCCTGTGAGCTGAAAAACTTAGCCGGGGACAATGGAGGTGCTGGGTTTGGTGGATATTCCGACATG")38 )39 y = SeqRecord(Seq("GCTGAACTTAGCCGGGGACAATG"))40 print(f"Test 1: Got {strand_guess(aligner, x, y)}, expecting 1")41 # x aligns with the forward strand of y with a small insertion42 x = SeqRecord(Seq("GCTGAACTTAGCCGGGGACAATG"))43 y = SeqRecord(44 Seq("CATCAAGCCCTGTGAGCTGAAAAACTTAGCCGGGGACAATGGAGGTGCTGGGTTTGGTGGATATTCCGACATG")45 )46 print(f"Test 2: Got {strand_guess(aligner, x, y)}, expecting 1")47 # x aligns with the reverse strand of y with a small insertion48 x = SeqRecord(49 Seq("CATGTCGGAATATCCACCAAACCCAGCACCTCCATTGTCCCCGGCTAAGTTTTTCAGCTCACAGGGCTTGATG")50 )51 y = SeqRecord(Seq("GCTGAACTTAGCCGGGGACAATG"))52 print(f"Test 3: Got {strand_guess(aligner, x, y)}, expecting -1")53 # x aligns with the reverse strand of y with a small insertion54 x = SeqRecord(Seq("GCTGAACTTAGCCGGGGACAATG"))55 y = SeqRecord(56 Seq("CATGTCGGAATATCCACCAAACCCAGCACCTCCATTGTCCCCGGCTAAGTTTTTCAGCTCACAGGGCTTGATG")57 )...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful