Questions tagged [pysam]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
33 views

How to convert BAM file to bigWig in Python?

I am manipulating some BAM files using pysam package which seems to be very fast and handy. However, I ran into problem when I am trying to generate bigWig files ...
2
votes
1answer
64 views

Is there a tool that can perform a read-group-aware mpileup from a single file?

I would like to perform a samtools mpileup from a single file that contains thousands of read groups with different SM tags. I could split the bam by read group ...
1
vote
1answer
36 views

How to filter a SAM file by a bed file?

I have a large BAM file and I want to filter it by just what's defined in a bed file, and write it to a new file. Is it possible to do this with samtools, and if so, how? Is there a better tool I ...
3
votes
1answer
94 views

pysam or piping samtools view to a python script

Is it faster to use the PySam package to run a python script on a bam for read in samfile.fetch('chr1', 100, 120): print read compared to using a pipe and ...
1
vote
1answer
289 views

Convert paired-end BAM into a single-end BAM and keep all the reads

I want to call peaks using MACS2 on my paired-end ATAC-seq BAM and I am interested in cutting sites. So I make use of the -BAM option (opposed to the -BAMPE) option. However this throws away all the ...
0
votes
1answer
217 views

filter secondary alignments using pysam

I am new to python and trying to learn. The below is an attempt to filter out secondary reads in a bam using ...
5
votes
2answers
404 views

What does “fetching by region is not available for SAM files” mean?

I am used to gzip/biopython solutions when dealing with sequencing data, but now I wish to switch to more elegant ...
2
votes
2answers
326 views

Access base aligned to particular reference position

The short version: If I have a SAM record, is there any simple way to retrieve the base aligned to a particular reference position without computing a pileup? The long version: I'm using pysam to ...
1
vote
1answer
52 views

Aligned base strand in pysam `pileupcolumn`

Is it possible that on the same pileupcolumn object (i.e a specific aligned base) I find the same base but aligned to different strands? For example, can I find a coverage of 50 'A's that align to ...
1
vote
2answers
395 views

Chunk alignment in a name sorted bam for parallel processing

I have a bam file with 1 billion alignment reads of which there are 700 million unique reads. I want to split the alignments into chunks for parallel-processing. Multi-alignments of the same read ...
3
votes
1answer
488 views

How do I rewrite a read group using pysam?

I am trying to rewrite a SAM/BAM file with altered read group entries using pysam. In this simplified version, I want to take a BAM, and rewrite the SM tags in all read groups to the same string and ...
5
votes
1answer
415 views

Using pysam with cython: htslib/kstring.h not found

I'm trying to learn to use cython to speed up some code based on pysam. My issue is not strictly speaking about bioinformatics, but rather about building tools using a bioinformatics library. I hope ...
2
votes
1answer
463 views

pysam pileup: what reads appear in the pileup?

Cross-posted on Biostars (with no answers currently). I hope that's OK. I thought that iff a read matches the reference at a position, it would appear in the pileup column for that position. But ...
7
votes
1answer
1k views

Extracting the CIGAR string from a BAM via Python?

Is there a standard method in Python to extract a CIGAR string from the BAM? There are great libraries which parse the CIGAR, e.g. https://pypi.python.org/pypi/cigar/0.1 ...
7
votes
1answer
357 views

Reject reads with low quality bases from a Bam file through pysam

I have a code below: ...
7
votes
1answer
483 views

Filtering bases based on phred qualities with pysam

Is there a way to filter bases in BAM files based on phred quallities through python's pysam ? I have a code here that Takes the nucleobases per position from a BAM file using pysam's pileup ...
10
votes
1answer
584 views

Quantifying reads mapping to multiple loci

I have been using STAR for our RNA-Seq samples. The final.out log file reports percentage of uniquely mapped reads along with percentage of reads that map to ...