Questions tagged [sam]

Use this tag for questions specifically related to the text SAM format. For general questions about the SAM/BAM formats use the tag BAM.

Filter by
Sorted by
Tagged with
19 votes
2 answers
12k views

Obtaining uniquely mapped reads from BWA mem alignment

This is based on a question from betsy.s.collins on BioStars. The original post can be found here. Does anyone have any suggestions for other tags or filtering steps on BWA-generated BAM files that ...
gringer's user avatar
  • 13k
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 ...
Daniel Standage's user avatar
18 votes
3 answers
13k views

How can I downsample a BAM file while keeping both reads in pairs?

I know how to downsample a BAM file to lower coverage. I know I can randomly select lines in SAM, but this procedure can't guarantee two reads in a pair are always sampled the same time. Is there a ...
medbe's user avatar
  • 777
42 votes
4 answers
56k views

What is the difference between FASTA, FASTQ, and SAM file formats?

I'd like to learn the differences between 3 common formats such as FASTA, FASTQ and SAM. How they are different? Are there any benefits of using one over another? Based on Wikipedia pages, I can't ...
kenorb's user avatar
  • 1,305
20 votes
12 answers
2k views

Random access on a FASTQ file

I would like to select a random record from a large set of n unaligned sequencing reads in log(n) time complexity (big O ...
winni2k's user avatar
  • 2,166
9 votes
2 answers
11k views

Converting a BAM file into VCF

I have NGS illumina RNA-seq reads from M. musculus (mm10). I am trying to find variants along the strand portion of the reads in the refseq (mm10). I mapped a pair of sequence files and generated a ...
Lou_A's user avatar
  • 361
8 votes
4 answers
1k views

How to manipulate a reference FASTA or bam to include variants from a VCF?

I have some software which takes fastas as the input. I need to include SNVs and InDels from a VCF into the reference hg38 and then use this. The problem is, I don't know of an algorithmically sound ...
ShanZhengYang's user avatar
8 votes
2 answers
545 views

How to import a large amount of .bed, .gff, .vcf, .paf, .sam files into an SQL database?

Are there best practices to load different bioinformatics file formats such as VCF, BED, GFF, and SAM to SQL databases? I am wondering how people out there do that efficiently. All of these three ...
0x90's user avatar
  • 1,417
8 votes
7 answers
9k views

How to subset a BAM by a list of QNAMEs?

I have a text file 'qnames.txt' with QNAMEs in the following format: EXAMPLE:QNAME1 EXAMPLE:QNAME2 EXAMPLE:QNAME3 EXAMPLE:QNAME4 EXAMPLE:QNAME5 I would like to ...
EB2127's user avatar
  • 1,373
8 votes
3 answers
3k views

How to merge sam files together with adding read groups

I have three sequencing libraries of single individual mapped to a reference using bwa-mem. I would like to merge the three unsorted ...
Kamil S Jaron's user avatar
7 votes
1 answer
774 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 ...
Ammar Sabir Cheema's user avatar
7 votes
1 answer
749 views

ethnicity check either from bam or vcf files

What tool could I use to check the ethnicity of a human bam or vcf file? I would like to use the results as a QC check to know whether a given sample or set of samples match the ethnicity information ...
719016's user avatar
  • 2,274
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 ...
ShanZhengYang's user avatar
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 ...
mattm's user avatar
  • 744
6 votes
1 answer
2k views

Read counts from BAM file

I have few BAM files which are generated from Ion Torrent Server (ampliseq) aligned to hg19 genome. I want to extract read counts from the bam files and I know that "featureCounts" can be used for ...
stack_learner's user avatar
6 votes
1 answer
577 views

Why most aligners do not output the "X" CIGAR operation?

As I read the SAM spec, the "X" CIGAR operator represents a mismatch. This seems useful as we can know where are the mismatches without looking at the reference genome. However, many popular aligners ...
medbe's user avatar
  • 777
3 votes
1 answer
1k views

Disk space error while aligning reads using STAR

Hi am trying to align RNA-seq reads using STAR through following commands, ...
Ammar Sabir Cheema's user avatar
2 votes
1 answer
485 views

Mark BWA-SW split alignments in output for long reads

Is there a way to remove split alignments of single-end long reads from BWA-SW output? BWA-MEM has an option to include or flag split alignments in the result, but it seems BWA-SW method include them ...
Mehrdad Bakhtiari's user avatar
1 vote
2 answers
1k views

Extract reads from bam files by their @RG

How could I extract reads from bam files by their read groups @RG ?, I've got one file containing all reads for 5 samples, the SM is appears NONE, So, I want to extract each sample reads by the @RG ...
Maloki's user avatar
  • 11