MACS3.IO.Parser module
Input parsers used across MACS3 for reading alignment-like formats.
This code is free software; you can redistribute it and/or modify it under the terms of the BSD License (see the file LICENSE included with the distribution).
- class MACS3.IO.Parser.BAMPEParser
Bases:
BAMParserParser for paired-end BAM files that yields fragment spans.
- n
Total number of fragments.
- d
Average fragment length.
- append_petrack(petrack)
Append inferred fragments to an existing
PETrackI.- Parameters:
petrack – Existing paired-end track to append to.
- Returns:
The updated track instance.
- Return type:
Examples
from MACS3.IO.Parser import BAMPEParser parser = BAMPEParser("reads.bam") petrack = parser.build_petrack() # Later, append more fragments from another file: parser2 = BAMPEParser("more_reads.bam") petrack = parser2.append_petrack(petrack)
- class MACS3.IO.Parser.BAMParser
Bases:
GenericParserParser for BAM binary alignment files.
- append_fwtrack(fwtrack)
Append uniquely mapped reads to an existing
FWTrack.
- build_fwtrack()
Append uniquely mapped reads to an existing
FWTrack.
- get_references()
Return
(references, lengths)extracted from the BAM header.
- sniff()
Return
Trueif the file begins with the BAM magic string.
- tsize()
Get tag size from BAM file – read l_seq field.
Refer to: http://samtools.sourceforge.net/SAM1.pdf
This may not work for BAM file from bedToBAM (bedtools),
since the l_seq field seems to be 0.
- class MACS3.IO.Parser.BEDPEParser
Bases:
GenericParserParser for three-column BEDPE-style fragments (chrom, left, right).
- append_petrack(petrack)
Append fragments from the stream to an existing
PETrackI.
- class MACS3.IO.Parser.BEDParser
Bases:
GenericParserParser for standard BED records with optional strand column.
- class MACS3.IO.Parser.BowtieParser
Bases:
GenericParserParser for Bowtie or Maqview single-end map files.
- class MACS3.IO.Parser.ELANDExportParser
Bases:
GenericParserParser for ELAND export tab-delimited files.
- class MACS3.IO.Parser.ELANDMultiParser
Bases:
GenericParserParser for ELAND multi-hit reports (
s_N_eland_multiformat).
- class MACS3.IO.Parser.ELANDResultParser
Bases:
GenericParserParser for single-end ELAND result tables.
- class MACS3.IO.Parser.FragParser
Bases:
GenericParserParser for scATAC fragment TSV files with barcode counts.
- append_petrack(petrack, max_count=0)
Append barcode-aware fragments to an existing
PETrackI.- Parameters:
petrack – Existing paired-end track to append to.
max_count – Optional cap applied to per-fragment count values.
- Returns:
The updated track instance.
- Return type:
Examples
from MACS3.IO.Parser import FragParser parser = FragParser("fragments.tsv.gz") petrack = parser.build_petrack() parser2 = FragParser("more_fragments.tsv.gz") petrack = parser2.append_petrack(petrack, max_count=10)
- build_petrack(max_count=0)
Return a
PETrackIIpopulated with fragments and barcodes.- Parameters:
max_count – Optional cap applied to per-fragment count values.
- Returns:
Paired-end track with barcode and count metadata.
- Return type:
Examples
from MACS3.IO.Parser import FragParser parser = FragParser("fragments.tsv.gz") petrack = parser.build_petrack(max_count=10)
- class MACS3.IO.Parser.GenericParser
Bases:
objectBase parser with helpers for streaming alignment-like text files.
- filename
Path to the input file.
- gzipped
Whether the input stream is gzipped. (bool)
- tag_size
tag size.
- fhd
Open file handle for the input stream.
- buffer_size
Buffer size for streaming reads.
- append_fwtrack(fwtrack)
Append parsed locations to an existing
FWTrack.
- build_fwtrack()
Create a new
FWTrackpopulated from the underlying stream.
- close()
Close the underlying file handle.
- is_gzipped()
Report whether the underlying input stream is gzip compressed.
- sniff()
Return
Truewhen the input appears compatible with this parser.
- tsize()
Estimate tag length from a sample of valid alignments.
- class MACS3.IO.Parser.SAMParser
Bases:
GenericParserParser for SAM alignment text files with standard SAM flags.
- MACS3.IO.Parser.guess_parser(fname, buffer_size=100000)
Return the first parser that recognises
fnameas a supported format.- Parameters:
fname – Path to inspect.
buffer_size (cython.long) – Buffer size handed to candidate parser constructors.
- Returns:
Parser instance configured for the detected format.
- Raises:
Exception – If no parser can identify the file structure.