def parse(infile, format, filters=None, splice_motif_file=None, noline=None, refseq=None): """Parse psl or sam file and returns alignment objects""" aligns = [] if format == 'psl': aligns = psl.parse(infile, filters, splice_motif_file=splice_motif_file, noline=noline, refseq=refseq) elif format == 'sam': aligns = sam.parse(infile, filters, splice_motif_file=splice_motif_file, noline=noline, refseq=refseq, header=True, original_order=True) return aligns
def parse_psl(self, minimum=False, refseq_2bit=None, refseq=None, splice_motif_file=None, just_blocks=False): """Extracts alignment or alignment blocks from psl file""" all_blocks = {} refseq = refseq if refseq_2bit: from tools import get_refseq_from_2bit refseq = get_refseq_from_2bit(refseq_2bit) aligns = psl.parse(self.track, noline=True, minimum=minimum, refseq=refseq, splice_motif_file=splice_motif_file) for align in aligns: align.query, align.coverage, orient, strand = self.get_contig_name(align.query) if just_blocks: all_blocks[align.query] = align.blocks if not just_blocks: return aligns else: return all_blocks