Questions tagged [pysam]
The pysam tag has no usage guidance.
24
questions
2
votes
1
answer
26
views
Is it possible to, all in memory without writing a file, given a list of AlignedSegments and a bam header, build a bam, index and get coverage?
My current job is rate-limited chiefly by the IO overhead of writing reads to their corresponding bam files (they are split up by both cell barcode and contig). The only reason I need to write these ...
2
votes
1
answer
55
views
Merge fragment reads
I'm writing a function (python) that merges overlapping paired reads of a fragment, and a corresponding reference sequence. There's quite a lot of edge cases (e.g. when the reads disagree on indels) ...
2
votes
1
answer
67
views
How to subsample BAM based on read line number?
Consider a sorted, indexed, only mapped reads containing BAM file.
Is there a way to get a sub BAM based on read line numbers?
For example get a sub BAM file which contains read line numbers [1, 3, 8, ...
1
vote
0
answers
37
views
How do I filter reads from a bamfile based on 5' and 3' ends?
I have data in paired-end as well as single-end format for the same sample.I would like to split those two files into two per each, where one contains sequences that have 5' end and the other one has ...
0
votes
0
answers
425
views
pysam "Exec format" error
I am a beginner and trying to read a bam file in Python.
The lines below throw the error
...
6
votes
1
answer
734
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 ...
1
vote
1
answer
471
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 ...
2
votes
2
answers
494
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 ...
4
votes
1
answer
274
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 ...
2
votes
2
answers
3k
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
1
answer
499
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
2
answers
1k
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
1
answer
955
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
2
answers
824
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 ...
5
votes
3
answers
1k
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
1
answer
155
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
2
answers
1k
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 ...
6
votes
1
answer
1k
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 ...
6
votes
1
answer
719
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
1
answer
928
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
2
answers
3k
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
1
answer
615
views
Reject reads with low quality bases from a Bam file through pysam
I have a code below:
...
7
votes
1
answer
863
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 ...
11
votes
1
answer
1k
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 ...