本文整理汇总了Python中Bio.Seq.MutableSeq.complement方法的典型用法代码示例。如果您正苦于以下问题:Python MutableSeq.complement方法的具体用法?Python MutableSeq.complement怎么用?Python MutableSeq.complement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.Seq.MutableSeq
的用法示例。
在下文中一共展示了MutableSeq.complement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMutableSeq
# 需要导入模块: from Bio.Seq import MutableSeq [as 别名]
# 或者: from Bio.Seq.MutableSeq import complement [as 别名]
#.........这里部分代码省略.........
self.mutable_s)
def test_inserting(self):
self.mutable_s.insert(4, "G")
self.assertEqual(MutableSeq("TCAAGAAGGATGCATCATG", IUPAC.ambiguous_dna),
self.mutable_s)
def test_popping_last_item(self):
self.assertEqual("G", self.mutable_s.pop())
def test_remove_items(self):
self.mutable_s.remove("G")
self.assertEqual(MutableSeq("TCAAAAGATGCATCATG", IUPAC.ambiguous_dna),
self.mutable_s, "Remove first G")
self.assertRaises(ValueError, self.mutable_s.remove, 'Z')
def test_count(self):
self.assertEqual(7, self.mutable_s.count("A"))
self.assertEqual(2, self.mutable_s.count("AA"))
def test_index(self):
self.assertEqual(2, self.mutable_s.index("A"))
self.assertRaises(ValueError, self.mutable_s.index, "8888")
def test_reverse(self):
"""Test using reverse method"""
self.mutable_s.reverse()
self.assertEqual(MutableSeq("GTACTACGTAGGAAAACT", IUPAC.ambiguous_dna),
self.mutable_s)
def test_reverse_with_stride(self):
"""Test reverse using -1 stride"""
self.assertEqual(MutableSeq("GTACTACGTAGGAAAACT", IUPAC.ambiguous_dna),
self.mutable_s[::-1])
def test_complement(self):
self.mutable_s.complement()
self.assertEqual(str("AGTTTTCCTACGTAGTAC"), str(self.mutable_s))
def test_complement_rna(self):
seq = Seq.MutableSeq("AUGaaaCUG", IUPAC.unambiguous_rna)
seq.complement()
self.assertEqual(str("UACuuuGAC"), str(seq))
def test_complement_mixed_aphabets(self):
seq = Seq.MutableSeq("AUGaaaCTG")
with self.assertRaises(ValueError):
seq.complement()
def test_complement_rna_string(self):
seq = Seq.MutableSeq("AUGaaaCUG")
seq.complement()
self.assertEqual('UACuuuGAC', str(seq))
def test_complement_dna_string(self):
seq = Seq.MutableSeq("ATGaaaCTG")
seq.complement()
self.assertEqual('TACtttGAC', str(seq))
def test_reverse_complement(self):
self.mutable_s.reverse_complement()
self.assertEqual("CATGATGCATCCTTTTGA", str(self.mutable_s))
def test_reverse_complement_of_protein(self):
seq = Seq.MutableSeq("ACTGTCGTCT", Alphabet.generic_protein)
with self.assertRaises(ValueError):
seq.reverse_complement()
def test_to_string_method(self):
"""This method is currently deprecated, probably will need to remove this test soon"""
with warnings.catch_warnings(record=True):
self.mutable_s.tostring()
def test_extend_method(self):
self.mutable_s.extend("GAT")
self.assertEqual(MutableSeq("TCAAAAGGATGCATCATGGAT", IUPAC.ambiguous_dna),
self.mutable_s)
def test_extend_with_mutable_seq(self):
self.mutable_s.extend(MutableSeq("TTT", IUPAC.ambiguous_dna))
self.assertEqual(MutableSeq("TCAAAAGGATGCATCATGTTT", IUPAC.ambiguous_dna),
self.mutable_s)
def test_delete_stride_slice(self):
del self.mutable_s[4:6 - 1]
self.assertEqual(MutableSeq("TCAAAGGATGCATCATG", IUPAC.ambiguous_dna),
self.mutable_s)
def test_extract_third_nucleotide(self):
"""Test extracting every third nucleotide (slicing with stride 3)"""
self.assertEqual(MutableSeq("TAGTAA", IUPAC.ambiguous_dna), self.mutable_s[0::3])
self.assertEqual(MutableSeq("CAGGTT", IUPAC.ambiguous_dna), self.mutable_s[1::3])
self.assertEqual(MutableSeq("AAACCG", IUPAC.ambiguous_dna), self.mutable_s[2::3])
def test_set_wobble_codon_to_n(self):
"""Test setting wobble codon to N (set slice with stride 3)"""
self.mutable_s[2::3] = "N" * len(self.mutable_s[2::3])
self.assertEqual(MutableSeq("TCNAANGGNTGNATNATN", IUPAC.ambiguous_dna),
self.mutable_s)
示例2: len
# 需要导入模块: from Bio.Seq import MutableSeq [as 别名]
# 或者: from Bio.Seq.MutableSeq import complement [as 别名]
print len(seq)
#seq[0]='C' #aren't mutables
st=str(seq) #toString
print st
#tipo de dato secuencia editable
from Bio.Seq import MutableSeq
mut_seq=seq.tomutable() #convertirlo a tipo seq mutable
print mut_seq
mut_seq[0]='C'
print mut_seq
mut_seq=MutableSeq('ATGCCG',IUPAC.IUPACUnambiguousDNA())
#has methods as a list: append(), insert(), pop(), remove()
mut_seq[1:3]='TTT'
mut_seq.reverse()
mut_seq.complement()
print mut_seq
mut_seq.reverse_complement()
print mut_seq
#tipo de dato metadatos de secuencia
from Bio.SeqRecord import SeqRecord
seqrec=SeqRecord(seq,id='001', name='My Secuencia')
#2 main attributes:
# id: string identifier, optional, recommended
# seq: Seq object, required
#additional attributes
# name, description: name and more info of sequence
# dbxrefs: list of strings, each string an id of a DB
# features: list of SeqFeature objects, those found in Genbank records
# annotations: dictionary with further info, can't be set on initialization