# Tag Info

Accepted

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

Let’s start with what they have in common: All three formats store sequence data, and sequence metadata. Furthermore, all three formats are text-based. However, beyond that all three formats are ...
• 4,745

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

In a nutshell, FASTA file format is a DNA sequence format for specifying or representing DNA sequences and was first described by Pearson ...
• 309
Accepted

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

No, samtools (and therefore bcftools) does not use soft-clipped bases. You can quickly confirm this by using either samtools depth or ...
• 19.3k
Accepted

### Why do SAM and BAM use different coordinate systems?

Arithmetic on a zero-based coordinate system is less complicated than that on a one-based system, so it appears zero-based is often (not exclusively) used for binary data formats, like BAM or bigBed, ...
• 3,045
Accepted

The sample tag (i.e. SM) was a mandatory tag in the initial SAM spec (see the .pages file; you need a mac to open it). When transitioned to Latex, this requirement ...
• 5,645
Accepted

### True bam file encoding and viewing as text

Why not work only with sam files and we need to convert them to bam? SAM is for human only, a binary format like BAM is smaller and parsed much faster by a program (and we want speed and optimize ...
• 1,473
Accepted

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

The SAM format originally had only M, I, D, N, S, H, and P CIGAR operators. See the original SAM specification (if you can view Apple Pages documents) and Table 1 in The Sequence Alignment/Map format ...

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

FASTA (officially) just stores the name of a sequence and the sequence, unofficially people also add comment fields after the name of the sequence. FASTQ was invented to store both sequence and ...
• 744

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

I modified your original question: as you are extracting 4 fields, you are not outputting BAM. The answer to the modified question is: yes, you can write a C program with htslib (or with bamtools, ...
• 5,645
Accepted

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

The BAM file format is not a text-based format. It has a specific binary structure, specified in reasonable detail in the SAM file format specification. Whenever this information is displayed on a ...
• 11.5k
Accepted

### How to Sort and Index a SAM file without converting it to BAM?

Not only will you save disk space by converting to BAM, but BAM files are faster to manipulate than SAM. Source: Dave Tang's SAMTools wiki. sort supports ...
• 443
Accepted

Your first command only needs a slight modification to add in -h. This will create a SAM file with a header. ...
• 11.5k
Accepted

I have used https://github.com/ekg/bamaddrg to add read groups quickly to multiple sam files. And then you can do a samtools merge of the tagged files.
• 2,566

### How should the SAM MD tag match the CIGAR string?

The MD string doesn't apply to soft or hard clipped regions,. so your example read becomes 43G42. Since variant calling using something simplistic like this is only ...
• 19.3k
Accepted

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

Assuming both the MD and CIGAR are present and correct, then yes, you can parse both to get the edit distance (NM auxiliary tag). One big caveat to this is that ...
• 19.3k

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

FASTA and FASTQ formats are both file formats that contain sequencing reads while SAM files are these reads aligned to a reference sequence. In other words, FASTA and FASTQ are the "raw data"...
• 193
Accepted

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

This can be done rather simply by combining this samtools based answer and bioawk: ...
• 2,930

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

Another library you can use for this purpose is the htsjdk, which is written in java. Using htsjdk with java is analogous to using htslib with C; the BAM format is already handled by the library and ...
• 714

### Number of reference sequences in a SAM file

There are multiple ways. Here are two: samtools idxstats ‹bamfile› samtools view -H ‹bamfile› | grep '^@SQ' Both commands give ...
• 4,745

### True bam file encoding and viewing as text

Assuming you want to visualize the pileup of reads across the reference, you may want to look into ASCIIgenome, a command line visualization tool for sam/bam/cram files, similar in spirit as IGV, but ...
• 917

### True bam file encoding and viewing as text

The way to visualise BAM files as text in Linux is with tools like samtools. If you want to see the raw binary information as slightly more human-readable, you can run ...
• 11.5k
Accepted

### Interpreting 0x200 flag in bwa-mem alignments

bwa mem is using exactly the same meaning of the 0x200 flag as every other program, including picard. Don't blindly assume that that entry in the header file ...
• 19.3k

### While opening a Bam file with the SeqAn library I get 'seqan::FileOpenError'

Remove the getAbsolutePath call — your path is already absolute. getAbsolutePath garbles it, as you can see in the error message....
• 4,745

The read group identifier needs to be specified in both the header lines of the BAM/SAM file and the alignment line. No other fields are required, but note that because the additional information is ...
• 11.5k

Not so elegant but working solution I found a solution that satisfy several of my conditions, basically I just have to assign read groups to individual mapping files, which can be just added to ...
• 5,287

### True bam file encoding and viewing as text

bam file is a compressed sam file, comparable with zip or tar. They are binary, which means we (humans) cannot read them. So you need to unpack them (convert back to sam) to read it as a text file. ...
• 3,531

### Extract end position from CIGAR

The start position is the first correctly mapped base. One way to do it, is to use GenomicAlignments in R to read in the alignments. For example the sam file looks like this: ...
• 1,638
Accepted

### Is there a sam flag for all&none of the reads?

Instead of doing this kind of tweaking I would write my script in a way that these options are passed as strings that can be empty. Something like: ...
• 2,706

### Convert local alignments to spliced alignments in SAM file

Just use minimap2 in split alignment mode to realign the reads. If that is not an option, then you could try using pysam to modify the CIGAR strings. I do not recommend this, as there are many ...
• 2,051

### Parsing SAM/BAM files for additional information

Other options... samtools stats maybe gives you some of the stats you are after. Chances are you already have samtools so nothing additional to install. Also useful may be pysamstats, in particular ...
• 659

Only top scored, non community-wiki answers of a minimum length are eligible