本文整理汇总了Python中cogent.DNA.makeSequence方法的典型用法代码示例。如果您正苦于以下问题:Python DNA.makeSequence方法的具体用法?Python DNA.makeSequence怎么用?Python DNA.makeSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.DNA
的用法示例。
在下文中一共展示了DNA.makeSequence方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_gaps_at_both_ends
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_gaps_at_both_ends(self):
s = 'aaaccggttt'
s1 = DNA.makeSequence(s[:-2], Name="A")
s2 = DNA.makeSequence(s[2:], Name="B")
for a in self._aligned_both_ways(s1, s2, local=False):
self.assertEqual(matchedColumns(a), 6)
self.assertEqual(len(a), 10)
示例2: test_assemble_seq
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_assemble_seq(self):
"""should correctly fill in a sequence with N's"""
expect = DNA.makeSequence("NAAAAANNCCCCCNNGGGNNN")
frags = ["AAAAA","CCCCC","GGG"]
positions = [(11, 16), (18, 23), (25, 28)]
self.assertEqual(_assemble_seq(frags, 10, 31, positions), expect)
positions = [(1, 6), (8, 13), (15, 18)]
self.assertEqual(_assemble_seq(frags, 0, 21, positions), expect)
# should work with:
# start matches first frag start
expect = DNA.makeSequence("AAAAANNCCCCCNNGGGNNN")
positions = [(0, 5), (7, 12), (14, 17)]
self.assertEqual(_assemble_seq(frags, 0, 20, positions), expect)
# end matches last frag_end
expect = DNA.makeSequence("NAAAAANNCCCCCNNGGG")
positions = [(11, 16), (18, 23), (25, 28)]
self.assertEqual(_assemble_seq(frags, 10, 28, positions), expect)
# both start and end matched
expect = DNA.makeSequence("AAAAANNCCCCCNNGGG")
positions = [(10, 15), (17, 22), (24, 27)]
self.assertEqual(_assemble_seq(frags, 10, 27, positions), expect)
# one frag
expect = DNA.makeSequence(''.join(frags))
positions = [(10, 23)]
self.assertEqual(_assemble_seq([''.join(frags)],10,23,positions),
expect)
示例3: test_local_tiebreak
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_local_tiebreak(self):
"""Should pick the first best-equal hit rather than the last one"""
# so that the Pyrex and Python versions give the same result.
score_matrix = make_dna_scoring_dict(match=1, transition=-1,
transversion=-1)
pattern = DNA.makeSequence('cwc', Name='pattern')
two_hit = DNA.makeSequence( 'cactc', Name= 'target')
aln = local_pairwise(pattern, two_hit, score_matrix, 5, 2)
hit = aln.NamedSeqs['target']
self.assertEqual(str(hit).lower(), 'cac')
示例4: setUp
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def setUp(self):
self.cigar_text = '3D2M3D6MDM2D3MD'
self.aln_seq = DNA.makeSequence('---AA---GCTTAG-A--CCT-')
self.aln_seq1 = DNA.makeSequence('CCAAAAAA---TAGT-GGC--G')
self.map, self.seq = self.aln_seq.parseOutGaps()
self.map1, self.seq1 = self.aln_seq1.parseOutGaps()
self.slices = [(1, 4), (0, 8), (7, 12), (0, 1), (3, 5)]
self.aln = LoadSeqs(data = {"FAKE01": self.aln_seq, "FAKE02": self.aln_seq1})
self.cigars = {"FAKE01": self.cigar_text, "FAKE02": map_to_cigar(self.map1)}
self.seqs = {"FAKE01": str(self.seq), "FAKE02": str(self.seq1)}
示例5: test_picklability
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_picklability(self):
"""Pickle an alignment containing an annotated sequence"""
# This depends on alignments, sequences, features, maps and spans
# Doesn't test round trip result is correct, which should possibly
# be done for maps/spans, but seqs/alignments are just simple
# python classes without __getstate__ etc.
import cPickle as pickle
seq1 = DNA.makeSequence("aagaagaagaccccca")
seq2 = DNA.makeSequence("aagaagaagaccccct")
seq2.addFeature('exon', 'fred', [(10,15)])
aln = LoadSeqs(data={'a':seq1, 'b':seq2})
aln2 = pickle.loads(pickle.dumps(aln))
示例6: _make_utr_seq
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def _make_utr_seq(self):
if self.UntranslatedExons5 is None and self.UntranslatedExons3 is None:
self._cached["Utr5"] = self.NULL_VALUE
self._cached["Utr3"] = self.NULL_VALUE
return
Utr5_seq, Utr3_seq = DNA.makeSequence(""), DNA.makeSequence("")
for exon in self.UntranslatedExons5:
Utr5_seq += exon.Seq
for exon in self.UntranslatedExons3:
Utr3_seq += exon.Seq
self._cached["Utr5"] = Utr5_seq
self._cached["Utr3"] = Utr3_seq
示例7: test_codon
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_codon(self):
s1 = DNA.makeSequence('tacgccgta', Name="A")
s2 = DNA.makeSequence('tacgta', Name="B")
codon_model = cogent.evolve.substitution_model.Codon(
model_gaps=False, equal_motif_probs=True,
mprob_model='conditional')
tree = cogent.LoadTree(tip_names=['A', 'B'])
lf = codon_model.makeLikelihoodFunction(tree, aligned=False)
lf.setSequences(dict(A=s1, B=s2))
a = lf.getLogLikelihood().edge.getViterbiPath().getAlignment()
self.assertEqual(matchedColumns(a), 6)
self.assertEqual(len(a), 9)
示例8: test
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test(r=1, **kw):
S = make_dna_scoring_dict(10, -1, -8)
seq2 = DNA.makeSequence("AAAATGCTTA" * r)
seq1 = DNA.makeSequence("AATTTTGCTG" * r)
t0 = time.time()
aln = classic_align_pairwise(seq1, seq2, S, 10, 2, local=False, **kw)
t = time.time() - t0
return (len(seq1) * len(seq2)) / t
print t
示例9: test
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test(r=1, **kw):
S = make_dna_scoring_dict(10, -1, -8)
seq2 = DNA.makeSequence('AAAATGCTTA' * r)
seq1 = DNA.makeSequence('AATTTTGCTG' * r)
t0 = time.clock()
try:
# return_alignment is False in order to emphasise the quadratic part of the work.
aln = classic_align_pairwise(seq1, seq2, S, 10, 2, local=False, return_alignment=False, **kw)
except ArithmeticError:
return '*'
else:
t = time.clock() - t0
return int ( (len(seq1)*len(seq2))/t/1000 )
示例10: test_inherit_feature
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_inherit_feature(self):
"""should be able to subclass and extend _Feature"""
class NewFeat(_Feature):
def __init__(self, *args, **kwargs):
super(NewFeat, self).__init__(*args, **kwargs)
def newMethod(self):
if len(self.map.spans) > 1:
as_one = self.asOneSpan() # should create new instance of NewFeat
return as_one.newMethod()
return True
seq = DNA.makeSequence('ACGTACGTACGT')
f = seq.addAnnotation(NewFeat, as_map([(1,3), (5,7)], len(seq)),
type='gene', Name='abcd')
self.assertEqual(type(f.asOneSpan()), NewFeat)
self.assertEqual(type(f.getShadow()), NewFeat)
f2 = seq.addAnnotation(NewFeat, as_map([(3,5)], len(seq)),
type='gene', Name='def')
self.assertEqual(type(seq.getRegionCoveringAll([f, f2],
feature_class=NewFeat)),
NewFeat)
# now use the new method
f.newMethod()
示例11: findBestSeq
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def findBestSeq(seqobject):
dna_seq = str(seqobject.seq)
my_seq = DNA.makeSequence(dna_seq,seqobject.id)
# x=0
# framedict = dict()
# while x < 3:
# temp1 = my_seq[x:]
# temp2 = temp1..withoutTerminalStopCodon()
# framedict[x] = temp2.getTranslation()
# x+=1
all_six = standard_code.sixframes(my_seq)
seqlist = list()
for frame in all_six:
seqreturned = frame.split('*')[0]
seqlist.append(seqreturned)
longestseq = ''
x=0
while x < 3:
if len(longestseq) < len(seqlist[x]):
longestseq = seqlist[x]
correctdnaseq = my_seq[x:]
x+=1
#longest_seq = max(seqlist, key=len)
return longestseq, correctdnaseq
示例12: _get_flanking_seq_data
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def _get_flanking_seq_data(self):
# maps to flanking_sequence through variation_feature_id
# if this fails, we grab from genomic sequence
variation_id = self._table_rows['variation_feature']['variation_id']
flanking_seq_table = self.flanking_sequence_table
query = sql.select([flanking_seq_table],
flanking_seq_table.c.variation_id == variation_id)
record = asserted_one(query.execute())
self._table_rows['flanking_sequence'] = record
up_seq = record['up_seq']
down_seq = record['down_seq']
# the following two lines are because -- wait for it -- someone has
# entered the string 'NULL' instead of NULL in the MySQL tables!!!
up_seq = [up_seq, None][up_seq == 'NULL']
down_seq = [down_seq, None][down_seq == 'NULL']
seqs = dict(up=up_seq, down=down_seq)
for name, seq in seqs.items():
if seq is not None:
seq = DNA.makeSequence(seq)
else:
resized = [(-301, -1), (1, 301)][name == 'down']
if self.Location.Strand == -1:
resized = [(1, 301), (-301, -1)][name == 'down']
flank = self.Location.resized(*resized)
flanking = self.genome.getRegion(region=flank)
seq = flanking.Seq
seqs[name] = seq
self._cached[('FlankingSeq')] = (seqs['up'][-300:],seqs['down'][:300])
示例13: CigarParser
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def CigarParser(seqs, cigars, sliced = False, ref_seqname = None, start = None, end = None, moltype=DNA):
"""return an alignment from raw sequences and cigar strings
if sliced, will return an alignment correspondent to ref sequence start to end
Arguments:
seqs - raw sequences as {seqname: seq}
cigars - corresponding cigar text as {seqname: cigar_text}
cigars and seqs should have the same seqnames
MolType - optional default to DNA
"""
data = {}
if not sliced:
for seqname in seqs.keys():
aligned_seq = aligned_from_cigar(cigars[seqname],
seqs[seqname], moltype=moltype)
data[seqname] = aligned_seq
else:
ref_aln_seq = aligned_from_cigar(cigars[ref_seqname],
seqs[ref_seqname], moltype=moltype)
m, aln_loc = slice_cigar(cigars[ref_seqname], start, end, by_align = False)
data[ref_seqname] = ref_aln_seq[aln_loc[0]:aln_loc[1]]
for seqname in [seqname for seqname in seqs.keys() if seqname != ref_seqname]:
m, seq_loc = slice_cigar(cigars[seqname], aln_loc[0], aln_loc[1])
if seq_loc:
seq = seqs[seqname]
if isinstance(seq, str):
seq = moltype.makeSequence(seq)
data[seqname] = seq[seq_loc[0]:seq_loc[1]].gappedByMap(m)
else:
data[seqname] = DNA.makeSequence('-'*(aln_loc[1] - aln_loc[0]))
aln = LoadSeqs(data = data, aligned = True)
return aln
示例14: makeSampleSequence
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def makeSampleSequence():
seq = 'tgccnwsrygagcgtgttaaacaatggccaactctctaccttcctatgttaaacaagtgagatcgcaggcgcgccaaggc'
seq = DNA.makeSequence(seq)
v = seq.addAnnotation(annotation.Feature, 'exon', 'exon', [(20,35)])
v = seq.addAnnotation(annotation.Feature, 'repeat_unit', 'repeat_unit', [(39,49)])
v = seq.addAnnotation(annotation.Feature, 'repeat_unit', 'rep2', [(49,60)])
return seq
示例15: test_stop_indexes
# 需要导入模块: from cogent import DNA [as 别名]
# 或者: from cogent.DNA import makeSequence [as 别名]
def test_stop_indexes(self):
"""should return stop codon indexes for a specified frame"""
sgc = GeneticCode(self.SGC)
seq = DNA.makeSequence("ATGCTAACATAAA")
expected = [[9], [4], []]
for frame, expect in enumerate(expected):
got = sgc.getStopIndices(seq, start=frame)
self.assertEqual(got, expect)