本文整理汇总了Python中HTSeq.parse_GFF_attribute_string方法的典型用法代码示例。如果您正苦于以下问题:Python HTSeq.parse_GFF_attribute_string方法的具体用法?Python HTSeq.parse_GFF_attribute_string怎么用?Python HTSeq.parse_GFF_attribute_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTSeq
的用法示例。
在下文中一共展示了HTSeq.parse_GFF_attribute_string方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: searchGeneName
# 需要导入模块: import HTSeq [as 别名]
# 或者: from HTSeq import parse_GFF_attribute_string [as 别名]
def searchGeneName(self,annotationstring):
if annotationstring == '.':
genes = 'N/A'
else:
# Split the annotationstring by ',' which collapsed by bedtools groupby
annotationstrings = annotationstring.split(',')
collect = set()
for annotation in annotationstrings:
try:
attr = HTSeq.parse_GFF_attribute_string(annotation)
# Search for gene_name which is used by ensembl gtf annotation
try:
gene = attr['gene_name']
except KeyError:
# Search for gene, which might used in GFF annotation
try:
gene = attr['gene']
except KeyError:
# Search for gene_id
try:
gene = attr['gene_id']
except KeyError:
try:
gene = attr['transcript_id']
except KeyError:
gene = 'N/A'
except:
gene = self.searchGeneName1(annotation)
collect.add(gene)
# Collapse all genes togethor
if len(collect) > 1:
try:
collect.remove('N/A')
except KeyError:
pass
genes = ','.join(collect)
return genes
示例2: intersectcirc
# 需要导入模块: import HTSeq [as 别名]
# 或者: from HTSeq import parse_GFF_attribute_string [as 别名]
def intersectcirc(self, circ_file, modified_gtf_file):
# imput the result file of print_start_end_file
import pybedtools
#intersectBed -a start.bed -b Drosophila_melanogaster.BDGP5.75.exon_id.dedup.gtf -wa -wb -loj > tmpintersect.2
circ = pybedtools.BedTool(circ_file)
gtf = pybedtools.BedTool(modified_gtf_file)
intersectfile = circ.intersect(gtf,wa=True,wb=True,loj=True)
# Store circExons as: circle start or end intervals as key, custom_exon_id as value
circExons = {}
for lin in intersectfile:
lin_split = str(lin).split('\t')
if lin_split[11].strip('\n') == '.':
#lin_split[11] = ''
pass
else:
circExons.setdefault( HTSeq.GenomicInterval(lin_split[0],int(lin_split[1]),int(lin_split[2]),lin_split[9]), set() ).add( HTSeq.parse_GFF_attribute_string(lin_split[11])['custom_exon_id'] )
#circExons.setdefault( HTSeq.GenomicInterval(lin_split[0],int(lin_split[1]),int(lin_split[2]),lin_split[9]), [] ).append( { HTSeq.GenomicInterval(lin_split[3],int(lin_split[6]),int(lin_split[7]),lin_split[9]):HTSeq.parse_GFF_attribute_string(lin_split[11]) })
return circExons