coverage¶
coverage module have 3 functions
- one which is an interface to pysam.
- an other with the same api to call the wig.chromosomes
- the third is a function selector accordingly the data input, wig or bam.
get_bam_coverage¶
Get coverage from pysam for reference (chromosome) for an interval of positions, a quality on both strand.
and convert the coverage return by pysam. A score on each position for each base (ACGT)) in a global coverage for this
position.
It also aligned all coverages return by pysam on the reference position by padding left and right by None.
This function is called for each entry of the annotation file.
get_wig_coverage¶
Get coverage from craw.wig.Genome instance for reference (chromosome) for an interval of positions, on both strand.
The quality parameter is here just to have the same signature as get_bam_coverage but will be ignores .
It also aligned all coverages return by the Chromosome on the reference position by padding left and right by None.
This function is called for each entry of the annotation file.
coverage API reference¶
craw.coverage.get_bam_coverage(sam_file, annot_entry, start=None, stop=None, qual_thr=15, max_left=0, max_right=0)[source]¶Compute the coverage for a region position by position on each strand
Parameters:
- sam_file (
pysam.AlignmentFileobject.) – the samfile openend with pysam- annot_entry (
annotation.Entryobject) – an entry of the annotation file- start (int) – The position to start to compute the coverage(coordinates are 0-based, start position is included).
- stop (int) – The position to start to compute the coverage (coordinates are 0-based, stop position is excluded).
- qual_thr (int) – The quality threshold
- max_left (int) – The highest number of base before the reference position to take in account.
- max_right (int) – The highest number of base after the reference position to take in account.
Returns: the coverage (all bases)
Return type: tuple of 2 list containing int
craw.coverage.get_coverage_function(input)[source]¶
Parameters: input ( wig.Genomeorpysam.calignmentfile.AlignmentFileobject) – the input either a samfile (see pysam library) or a genome build from a wig file (see wig module)Returns: get_wig_coverage or get_bam_coverage according the type of input Return type: function Raises RuntimeError: when input is not instance of pysam.calignmentfile.AlignmentFileorwig.Genome
craw.coverage.get_wig_coverage(genome, annot_entry, start=None, stop=None, max_left=0, max_right=0, qual_thr=None)[source]¶
Parameters:
- annot_entry (
annotation.Entryobject) – an entry of the annotation file- start (int) – The position to start to compute the coverage(coordinates are 0-based, start position is included).
- stop (int) – The position to start to compute the coverage (coordinates are 0-based, stop position is excluded).
- max_left (int) – The highest number of base before the reference position to take in account.
- max_right (int) – The highest number of base after the reference position to take in account.
- qual_thr (None) – this parameter is not used, It’s here to have the same api as get_bam_coverage.
Returns: the coverage (all bases)
Return type: tuple of 2 list containing int