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
0
votes
1answer
23 views

extract chimeric and multimap reads from bam file

I am trying to extract all chimeric and multi-map reads from either SAM/BAM file. Is there any simple command to do that? Can I use htslib for parsing sam/bam files ...
0
votes
1answer
27 views

Diploid Consensus Sequences

My goal is to generate a diploid consensus genome. By "diploid consensus", I mean that I want to merge all supporting reads for a genomic region into a single haplome such that the resulting ...
1
vote
1answer
64 views

How can I extract information from .sam files?

I have 10 .sam files after my bowtie2 alignment on ten single-pair sequences. I would like to build a graph based on that output ...
6
votes
1answer
96 views

How to import large .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 ...
-1
votes
1answer
22 views

How to identify to each scaffold a read belongs to, inside a .sam file?

I have a fasta file assembly and combining it with the raw reads we produced a .bam file which I converted to .sam . The .sam information lines look like this: ...
1
vote
0answers
42 views

How do I Read a Sam File into a String Using ifstream in C++?

I am trying to read a .sam file into a single string in C++. My end goal is to read this string into a vector, where tabs indicate separations between elements of the vector. After making a vector ...
1
vote
1answer
63 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 ...
0
votes
0answers
27 views

How do I find all supplementary mappings of a chimeric long (ONT) read mapped with NGMLR?

Unlike this guy How do I find split reads? I have done a lot of reading before asking this question. I'm aware that the FLAG will tell me if a read is supplementary and the CIGAR has information ...
0
votes
0answers
28 views

extracting genomic regions to which query sequences have been mapped

I have ddRAD sequences (already assembled from raw reads) and I wish to know to which regions of a reference genome they map. I successfully mapped the loci to the reference (using bowtie2), I got the ...
3
votes
1answer
56 views

Chromosomal order of supplementary alignment in BAM file “SA” tag

I have several long-read sequences, which when aligned to a human reference genome, aligns to multiple chromosomal fragment as a result of chromothripsis shattering the linear DNA and randomly piecing ...
1
vote
2answers
80 views

Extract end position from CIGAR

I was wondering how could I obtain the end position of an alignment using its start position and its CIGAR String. If an alignment present some soft clipping, for example: ...
1
vote
1answer
272 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
1k views

Convert PAF format to SAM/BAM format

I have a bunch of PAF files resulting from the alignments of fastq files on a reference genome with minimap2. I would like to convert them into SAM/BAM format so I can use ...
0
votes
0answers
44 views

How to obtain the extended unaligned bases of the read in reference based genome assembly?

I did illumina read mapping based on a particular gene sequence (reference sequence) using the following command, ...
2
votes
1answer
326 views

Consensus sequence from SAM or BAM file?

I am trying to perform reference-based assembly. Most of the tutorials teach how to create a bam file and view alignemnts in IGV or Tablet. But, I want a assembled genome sequence in fasta format. How ...
3
votes
0answers
112 views

convert supplementary reads to primary in sam or bam

I have a problem with a tool, that possibly ignores supplementary reads. I want to find out a bit how this tool works by converting all supplementary reads to primary reads, and then change the names ...
6
votes
2answers
252 views

Number of reference sequences in a SAM file

From a single record, I can get the reference sequence ID from the field rID, but how can I get the total number of different reference sequences stored in the whole SAM file? It can be simple as just ...
5
votes
2answers
1k views

How can I easily get the read size distribution of reads mapping on a certain set of regions?

Suppose I have a BAM file indicating where reads in a library have mapped, and a bed file describing a set of genomic regions. Is there a way to easily get the size distribution of the reads mapping ...
0
votes
1answer
131 views

While opening a Bam file with the SeqAn library I get 'seqan::FileOpenError' [closed]

When I try to open a simple bam file with the SeqAn library using the following code: ...
2
votes
1answer
860 views

Modifying a SAM header after removing all non-primary reads

I subset a BAM to only include primary reads using the following samtools commands: samtools view -F 256 input.bam > input.primaryOnly.sam Now, in order to ...
3
votes
3answers
220 views

Parsing SAM/BAM files for additional information

I used BWA-MEM to alignment and I would like to gather the some informations like total % of match, mismatch, insert/delete etc. I am wondering if there is any existing tools that produces this ...
1
vote
2answers
493 views

Mapping Information from SAM/BAM file

I mapped raw illumina reads to longer pacbio reads and I would like to know the following information from my mapping file (SAM/BAM) How many PacBio reads are mapped to at least one illumina reads A ...
4
votes
2answers
494 views

Interpreting 0x200 flag in bwa-mem alignments

I am looking at the bwamem.h code in http://github.com/lh3/bwa and found that BWA-MEM will give flag 0x200 to what it calls ...
2
votes
1answer
362 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 ...
3
votes
4answers
1k views

True bam file encoding and viewing as text

We all have been using samtools to convert between sam and bam files. SAM is tab-delimited file. My question resides on the ability to visualize bam files as text. Is there any way to visualize any ...
8
votes
1answer
209 views

Convert local alignments to spliced alignments in SAM file

I mapped RNA reads to reference genome, using LAST in split mode, and converted the MAF alignment to SAM with maf-convert. My problem is that the transcripts are not reported in a spliced manner, ...
7
votes
3answers
581 views

Is there a way to retrieve several SAM fields faster than `samtools view | cut -f`?

I am constructing a bit of software which pipes the outputs of the bam file via samtools view into a script for parsing. My goal is to (somehow) make this process ...
8
votes
2answers
2k 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 ...
5
votes
1answer
127 views

Is the optional SAM NM field strictly computable from the MD and CIGAR?

From SAM Optional Fields Specification the NM field is Edit distance to the reference, including ambiguous bases but excluding clipping Assuming both the MD and CIGAR are present, is the edit ...
6
votes
1answer
530 views

How should the SAM MD tag match the CIGAR string?

I am trying to understand how the MD:Z tag is used. The following is from the SAM Optional Fields Specification, which gives an example but is not thorough. The MD field aims to achieve SNP/indel ...
10
votes
2answers
251 views

What are the de facto required fields in a SAM/BAM read group?

The SAM specification indicates that each read group must have a unique ID field, but does not mark any other field as required. I have also discovered that htsjdk throws exceptions if the sample (...
6
votes
1answer
305 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 ...
13
votes
1answer
1k views

Are soft-clipped bases used for variant calling in samtools + bcftools?

If there are soft clipped base pairs specified in the CIGAR string for a read in a SAM/BAM file, will these be used for variant calling in a samtools + bcftools workflow? The GATK HaplotypeCaller, ...
34
votes
4answers
39k 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 ...