#NEWLINE# def readAsIntervals( gff_iterator , with_values = False , with_records = False , merge_genes = False , with_gene_id = False , with_transcript_id = False , use_strand = False ) : #NEWLINE# #INDENT# 'read tuples of (start, end) from a GTF file.\n\n    This method ignores everything else but the coordinates.\n\n    The `with_values`, `with_gene_id` and `with_records` options are\n    exclusive.\n\n    Arguments\n    ----------\n    gff_iterator : iterator\n       Iterator yielding GTF records.\n    with_values\n       If True, the content of the score field is added to the tuples.\n    with_records\n       If True, the entire record is added to the tuples.\n    merge_genes\n       If true, the GTF records are passed through the :func:\n       `merged_gene_iterator` iterator first.\n    with_gene_id\n       If True, the gene_id is added to the tuples.\n    with_transcript_id\n       If True, the transcript_ids are added to the tuples.\n    use_strand\n       If true, intervals will be grouped by contig and strand.\n       The default is to group by contig only.\n\n    Returns a dictionary of intervals by contig.\n\n    ' #NEWLINE# assert ( not ( with_values and with_records ) ) , 'both with_values and with_records are true.' #NEWLINE# intervals = collections . defaultdict ( list ) #NEWLINE# if merge_genes : #NEWLINE# #INDENT# it = merged_gene_iterator ( gff_iterator ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# it = gff_iterator #NEWLINE# #UNINDENT# if use_strand : #NEWLINE# #INDENT# keyf = ( lambda x : ( x . contig , x . strand ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# keyf = ( lambda x : x . contig ) #NEWLINE# #UNINDENT# if with_values : #NEWLINE# #INDENT# for gff in it : #NEWLINE# #INDENT# intervals [ keyf ( gff ) ] . append ( ( gff . start , gff . end , gff . score ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if with_records : #NEWLINE# #INDENT# for gff in it : #NEWLINE# #INDENT# intervals [ keyf ( gff ) ] . append ( ( gff . start , gff . end , gff ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if with_gene_id : #NEWLINE# #INDENT# for gff in it : #NEWLINE# #INDENT# intervals [ keyf ( gff ) ] . append ( ( gff . start , gff . end , gff . gene_id ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if with_transcript_id : #NEWLINE# #INDENT# for gff in it : #NEWLINE# #INDENT# intervals [ keyf ( gff ) ] . append ( ( gff . start , gff . end , gff . transcript_id ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for gff in gff_iterator : #NEWLINE# #INDENT# intervals [ keyf ( gff ) ] . append ( ( gff . start , gff . end ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# return intervals