Questions tagged [pysam]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
42 views

Error in pysam when running CrossMap.py liftover (KeyError: "sequence 'chr8' not present")

I am trying to liftover a VCF file from hg17 to hg19 using CrossMap and I am running into the following error: ...
user avatar
0 votes
0 answers
190 views

pysam "Exec format" error

I am a beginner and trying to read a bam file in Python. The lines below throw the error ...
user avatar
  • 11
6 votes
1 answer
347 views

Is there an efficient way to extract CIGAR strings for read pairs from bam files with python?

I am working with bam files and I have to check if reads of a specific position or their mates are soft clipped. So, I am looking for a fast way to extract the read pairs from a bam file in python. So ...
user avatar
  • 61
1 vote
1 answer
172 views

Find all the bases for given reference position

Hi im looking for the aligned bases in the reads for a given reference position. im using the following script from the pysam documentataion. I adjusted it to find the specified position. in this case ...
user avatar
2 votes
2 answers
363 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 ...
user avatar
4 votes
1 answer
194 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 ...
user avatar
  • 2,096
1 vote
1 answer
1k 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 ...
user avatar
  • 131
3 votes
1 answer
324 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 ...
user avatar
1 vote
2 answers
721 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 ...
user avatar
0 votes
1 answer
614 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 ...
user avatar
  • 113
5 votes
2 answers
679 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 ...
user avatar
  • 5,327
5 votes
3 answers
951 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 ...
user avatar
1 vote
1 answer
102 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 ...
user avatar
1 vote
2 answers
774 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 ...
user avatar
  • 11
6 votes
1 answer
853 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 ...
user avatar
  • 724
5 votes
1 answer
595 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 ...
user avatar
  • 3,010
2 votes
1 answer
750 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 ...
user avatar
  • 183
7 votes
2 answers
2k 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 ...
user avatar
7 votes
1 answer
513 views

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

I have a code below: ...
user avatar
7 votes
1 answer
674 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 ...
user avatar
10 votes
1 answer
895 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 ...
user avatar