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


Python Track.ucsc_targets方法代码示例

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


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

示例1: output_aligns

# 需要导入模块: from track import Track [as 别名]
# 或者: from track.Track import ucsc_targets [as 别名]
def output_aligns(outfile, aligns, track_name=None, contigs=None, append=False, 
                  header=True, genome=None, refseq=None, color=None, by_fasta=False, annodir=None):
    """Outputs alignments to file"""
    ext = os.path.splitext(outfile)[1]
    if append:
        out = open(outfile, 'a')
    else:
        out = open(outfile, 'w')
	
    # desc == name
    track_desc = track_name
    if aligns:
        if track_name and genome:
            Track.ucsc_targets(genome, aligns, annodir)
        
        if header and track_name:
	    header_line = "track name=\"%s\" description=\"%s\" visibility=%d itemRgb=\"On\"" % (track_name, track_desc, 3)
	    if color is not None:
		header_line += ' color=\"%s\"' % (color)
            out.write("%s\n" % (header_line))

        # map contig to contig name
        contig_dict = None
        if contigs:
            contig_dict = dict((contig.num, contig) for contig in contigs)
	    
	# sort alignments by contig order in original input fasta file
	if by_fasta:
	    count = 0
	    ordered = {}
	    for contig in contigs:
		ordered[contig.num] = count
		count += 1
	    aligns.sort(lambda x,y: ordered[x.query] - ordered[y.query])
            
        for align in aligns:
            contig = align.query
            if ' ' in contig:
                contig = align.query.split(" ")[0]
            
            if contig_dict and contig_dict.has_key(contig):
                align.contig = contig_dict[contig]
                                
            if ext == ".gff":
                out.write(align.gff("exon"))

            elif ext == ".psl":
                out.write(align.psl(refseq=refseq, genome=genome))
                
    out.close()
开发者ID:sara62,项目名称:transabyss,代码行数:52,代码来源:align_parser.py


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