当前位置: 首页>>代码示例>>Python>>正文


Python Tree.get_frame_paths方法代码示例

本文整理汇总了Python中Tree.get_frame_paths方法的典型用法代码示例。如果您正苦于以下问题:Python Tree.get_frame_paths方法的具体用法?Python Tree.get_frame_paths怎么用?Python Tree.get_frame_paths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


在下文中一共展示了Tree.get_frame_paths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import Tree [as 别名]
# 或者: from Tree import get_frame_paths [as 别名]
def main():
	s = RandomFSSequence( no_of_shifts=2, min_length=50, max_length=100 )
	s.generate()
	
	print s.info( "without UGA" )
	
	# a Sequence object
	#t = BiologicalSequence( s.sequence )
	#t = BiologicalSequence( "GCTGGTGGGGTAGCAGGTGTTTCTGTTGACTTGATATTATTTCCTCTGGATACCATTAAAACCAGGCTGCAGAGTCCCCAAGGATTTAGTAAGGCTGGTGGTTTTCATGGAATATATGCTGGCGTTCCTTCTGCTGCTATTGGATCCTTTCCTAATG" )
	t = BiologicalSequence( "AAATGACGAACACAGAGGAAAGAAGAGAGGCAACTGCTGAGGTCCCCTAGGCCTTTGAGAAAACGGAGTTGTACCTTTGGCAACATAAGTGCATATCTACAAGAAAGGCGATAATGTAGACACCAAGGGAATGGGTACTGTCCAAAAAGAAATGCCTCACAAATGTCACCATGGCAAAACTAAAAGAGTCTACAAAGTTACCTAGCATGCTGTTGGCATCATTGTAAACAAACAAGTTAAGGGCAAGATTCTTGCCAAGAGAATTAATATGCATATTGGGCATATTAAGCACTCTAAGAGCCAAGATGATTTCCTGAAAGTGTGTGAAGGAAAATAACCAGCATAAAGAGGGAAGCTAAAGAGAAACCTGAAGCTGCAGCCTGTTCCACCCAGAGAAGCACACTTTGTAAGAACCAATGAAAAGGAGCCTGAGCTGCTGGAGTCTATTAACTGAATTCATGGT" )
	#t = RandomSequence( 100 )
	#t.generate()
	# t.stops.append( "UGA" )
		
	print 
	print t.info()
	for i in xrange( 3 ):
		print t.colour_frame( i, sep="" )
	print "         |"*(( s.length )//10 )
	
	t.get_stop_sequence()
	
	print "The raw stop sequence (%s)..." % len( t.stop_sequence )
	print t.stop_sequence
	print
	
	# now to create paths
	p = Paths( t.stop_sequence )
	
	print "The sanitised stop sequence (%d)..." % len( p.unique_frame_sequence )
	print p.unique_frame_sequence
	print
	
	print "Create the branches from the stop sequence..."
	p.create_branches()
	print
	
	print "Create a tree..."
	T = Tree()
	
	print "View and graft the branches..."
	for B in p.branches:
		#print B
		T.graft( B )
	
	print T
	
	print "Build the paths..."
	
	paths = T.get_paths( simplify=True )
	print paths
	print
	
	for frame in xrange( 3 ):
		print "Frameshift sequences for frame %d:" % frame
		for j in T.get_frame_paths( frame ):
			print len( j ), " : ", j
		print
	
	"""
	frameshifted_sequence, fragments = t.frameshift_from_path( all_paths[0] )
	q = BiologicalSequence( s.sequence )
	print s.info()
	for i in xrange( 3 ):
		print q.colour_frame( i, sep="" )
	print "         |"*(( s.length )//10 )
	print
	
	print " ".join( fragments )
	print
	
	print t.path
	print t.colour_frameshifted_sequence( sep="" )
	print "         |"*(( s.length )//10 )
	"""
	
	for i in xrange( 3 ):
		all_paths = T.get_frame_paths( i )
		for a in all_paths:
			frameshifted_sequence, fragments, frameshift_signals = t.frameshift_from_path( a )
			print t.path
			print t.colour_frameshifted_sequence( sep="" )
			print " ".join( fragments )
			print " ".join( frameshift_signals )
			print
开发者ID:polarise,项目名称:BioClasses,代码行数:87,代码来源:test_Sequence2.py

示例2: Sequence

# 需要导入模块: import Tree [as 别名]
# 或者: from Tree import get_frame_paths [as 别名]

#.........这里部分代码省略.........
		self.frame_paths = dict() # all paths per frame
		self.sorted_frame_paths = dict() # sorted by length
		
		self.frameshift_sequences = dict()
		
		# get the raw start sequence
		self.get_start_sequence()
		if verbose: print >> sys.stderr, "Generated start sequence of length %d..." % len( self.start_sequence )
		
		# get the raw stop sequence
		self.get_stop_sequence()
		if verbose: print >> sys.stderr, "Generated stop sequence of length %d..." % len( self.stop_sequence )
		
		# sanitise the raw stop sequence
		self.sanitise_stop_sequence()
		if verbose: print >> sys.stderr, "Generated unique stop sequence of length %d..." % len( self.unique_stop_sequence )
		
		# create a list of branches
		self.create_branches()
		if verbose: print >> sys.stderr, "Creating branches..."
		
		# graft the branches to the tree
		if verbose: print >> sys.stderr, "Grafting branches to tree..."
		for B in self.branches:
			self.tree.graft( B, verbose )
		
		# get the paths
		self.paths = self.tree.get_paths( simplify=True )
		self.no_paths = len( self.paths )
		if verbose: print >> sys.stderr, "Found %d paths in tree." % self.no_paths
		
		# get paths per frame
		for frame in xrange( 3 ):
			self.frame_paths[frame] = self.tree.get_frame_paths( frame )
			
		# sort frame paths by length
		sorted_frame_paths = dict()
		for frame in xrange( 3 ):
			for path in self.frame_paths[frame]:
				path_len = len( path )
				if path_len not in sorted_frame_paths:
					sorted_frame_paths[path_len] = [ path ]
				else:
					sorted_frame_paths[path_len] += [ path ]
		
		all_path_len = sorted_frame_paths.keys()
		all_path_len.sort()
		
		for a in all_path_len:
			if a not in self.sorted_frame_paths:
				self.sorted_frame_paths[a] = sorted_frame_paths[a]
			else:
				self.sorted_frame_paths[a] += sorted_frame_paths[a]
		
		# get all frameshift sequences
		for frame in self.frame_paths:
			for path in self.frame_paths[frame]:
				self.frameshift_sequences[tuple(path)] = FrameshiftSequence( self.sequence, path )
	
	#*****************************************************************************
	
	def set_genetic_code( self, genetic_code ):
		self.genetic_code = genetic_code
	
	#*****************************************************************************
	
开发者ID:polarise,项目名称:BioClasses,代码行数:69,代码来源:Sequence.py


注:本文中的Tree.get_frame_paths方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。