NAME
cigar — a compact text-based format for representing pairwise alignments
DESCRIPTION
CIGAR (Compact Idiosyncratic Gapped Alignment Report) is a text-based format that encodes a pairwise alignment as a sequence of run-length encoded operations. Each operation describes a column of the alignment, or a run of identical consecutive columns, as seen from the query viewpoint. vsearch emits CIGAR strings in several search, clustering, and pairwise alignment outputs (see SEE ALSO).
A CIGAR string is an ASCII string consisting of one or more operations. Each operation is written as an optional non-negative integer run-length immediately followed by a single uppercase letter indicating the operation type:
[run-length] operation [run-length] operation ...
For example, 3M2I3MD describes an alignment that starts with three
matches or mismatches, followed by two query insertions, three matches
or mismatches, and a single deletion.
Operations
vsearch recognizes three operation types, corresponding to the three
possible column types in a gapped pairwise alignment (see
vsearch-pairwise_alignment_parameters(7)):
M
Match or mismatch. The column aligns one query residue with one target
residue. vsearch does not distinguish matches from mismatches in its
CIGAR strings.
I
Insertion. A residue is present in the query but absent from the target
(a gap in the target).
D
Deletion. A residue is present in the target but absent from the query
(a gap in the query).
Other operation letters defined by the SAM specification (X, =, N,
S, H, P) are not produced by vsearch and are rejected when reading
CIGAR strings.
Run-length encoding
Consecutive columns of the same operation type are grouped into a single
run. The number of columns in a run is written as a decimal integer
immediately before the operation letter. A run-length of 1 is implicit
and may be omitted: M is equivalent to 1M, and MID is equivalent
to 1M1I1D. Leading zeros are accepted (03M is equivalent to 3M). A
run-length of 0 is accepted and produces a zero-length operation.
Run-lengths are positive integers at most equal to the largest value
representable by the C int type (2,147,483,647 on most platforms, see
limits.h(0p)). There is no maximum total length for a CIGAR string.
Empty and missing alignments
An empty CIGAR string is valid and represents an empty alignment.
When a command reports that a query has no alignment to a target, the CIGAR field is replaced with a placeholder whose value depends on the output format:
- the
alnandcalnuserfields (--userout) produce an empty field; - the
--blast6outtabular output produces an empty field; - the
--samout(SAM) and--uc(UCLUST-like) outputs produce the single character*.
Exact-match shorthand
As a vsearch-specific convention, a CIGAR string consisting of the
single character = is emitted in --uc and --userout
(--userfields caln) outputs when the query is identical to the target,
ignoring terminal gaps. This shorthand is not part of the SAM
specification and is not produced in --samout or --blast6out
outputs, which always emit explicit operations.
Ill-formed strings
vsearch reports a fatal error when reading a CIGAR string that ends with
one or more digits not followed by an operation letter (for example
12M1), or that contains any character other than the digits 0–9
and the letters M, I, and D.
EXAMPLES
The following alignment of an 8-nt query against a 9-nt target
query: ACGT--TACG
target: AC-TGGTACG
cigar: 2M1I1M2D4M
contains, from left to right:
- 2 columns with matching residues (
AC/AC), - 1 insertion in the target (
Gpresent only in the query), - 1 column with matching residues (
T/T), - 2 deletions from the query (
GGpresent only in the target), - 4 columns with matching residues (
TACG/TACG).
The same alignment written without run-length compression would be
MMIMDDMMMM. Note that M does not distinguish matches from
mismatches; a mismatching column is encoded with the same operation
letter.
SEE ALSO
vsearch-allpairs_global(1),
vsearch-cluster_fast(1),
vsearch-cluster_size(1),
vsearch-cluster_smallmem(1),
vsearch-cluster_unoise(1),
vsearch-search_exact(1),
vsearch-usearch_global(1),
vsearch-pairwise_alignment_parameters(7),
vsearch-userfields(7)
CITATION
Rognes T, Flouri T, Nichols B, Quince C, Mahé F. (2016) VSEARCH: a versatile open source tool for metagenomics. PeerJ 4:e2584 doi: 10.7717/peerj.2584
REPORTING BUGS
Submit suggestions and bug-reports at https://github.com/torognes/vsearch/issues, send a pull request on https://github.com/torognes/vsearch, or compose a friendly or curmudgeont e-mail to Torbjørn Rognes (torognes@ifi.uio.no).
AVAILABILITY
Source code and binaries are available at https://github.com/torognes/vsearch.
COPYRIGHT
Copyright (C) 2014-2026, Torbjørn Rognes, Frédéric Mahé and Tomás Flouri
All rights reserved.
Contact: Torbjørn Rognes torognes@ifi.uio.no, Department of Informatics, University of Oslo, PO Box 1080 Blindern, NO-0316 Oslo, Norway
This software is dual-licensed and available under a choice of one of two licenses, either under the terms of the GNU General Public License version 3 or the BSD 2-Clause License.
GNU General Public License version 3
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
The BSD 2-Clause License
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ACKNOWLEDGMENTS
We would like to thank the authors of the following projects for making their source code available:
- vsearch includes code from Google’s CityHash project by Geoff Pike and Jyrki Alakuijala, providing some excellent hash functions available under a MIT license.
- vsearch includes code derived from Tatusov and Lipman’s DUST program that is in the public domain.
- vsearch includes public domain code written by Alexander Peslyak for the MD5 message digest algorithm.
- vsearch includes public domain code written by Steve Reid and others for the SHA1 message digest algorithm.
- vsearch binaries may include code from the zlib library, copyright Jean-Loup Gailly and Mark Adler.
- vsearch binaries may include code from the bzip2 library, copyright Julian R. Seward.