samtools-import(1)
samtools-import(1) π β¨
okay so this is the <pink>samtools-import(1)</pink> page from the bioinformatics tools fam β like, the actual literal manual β and bestie, we're gonna get through it together, no cap π«Ά
πΈ NAME πΈ
<mint>samtools import</mint> β converts FASTQ files to unmapped SAM/BAM/CRAM, slay π
β¨ SYNOPSIS β¨
samtools import [options] [ fastq_file ... ]
π¦ DESCRIPTION π¦
So basically it reads one or more FASTQ files and converts them into unmapped SAM, BAM or CRAM. The input files get automatically decompressed if they have a .gz extension β no extra steps, it just handles it for you π₯
The simplest usage, when you have literally zero other command line options, is to just hand it one or two input files.
If you give it a single file, it gets interpreted as single-ended sequencing format β unless the read names end with /1 and /2, in which case they get labelled as PAIRED with the READ1 or READ2 BAM flags set. If you give it a pair of filenames, it reads from them alternately to produce an interleaved output file, and also sets the PAIRED and READ1 / READ2 flags π«
You can also label the filenames explicitly: -1 and -2 for READ1 and READ2 data files, -s for an interleaved paired file (or one half of a paired-end run), -0 for unpaired data, and explicit index files with --i1 and --i2. These correspond to typical output produced by Illumina bcl2fastq and match the output from samtools fastq. The index files will set both the BC barcode code and its associated QT quality tag π
The Illumina CASAVA identifiers can also be processed when the -i option is given. This tag gets processed for READ1 / READ2, whether or not the read failed processing (that's the QCFAIL flag), plus the barcode sequence, which gets added to the BC tag. This can be an alternative to explicitly specifying the index files β although, heads up, doing it this way will not fill out the barcode quality tag π
π OPTIONS π
-s FILEβ import paired interleaved data fromFILE.-0 FILEβ import single-ended (unpaired) data fromFILE.
okay so real talk: operationally there is no difference between the -s and -0 options. Like, give either one an interleaved file with /1 and /2 read name endings and both will correctly set the PAIRED, READ1 and READ2 flags. And give them data with no suffixes and no CASAVA identifiers being processed, and both will leave the data as unpaired. So why do they exist? Because more descriptive command lines are iconic, and it improves the header comment describing the samtools fastq decode command π
-1 FILE,-2 FILEβ import paired data from a pair ofFILEs. The BAM flag PAIRED gets set, but not PROPER_PAIR, because hello, it hasn't been aligned. READ1 and READ2 get stored in their original, unmapped, orientation π§--i1 FILE,--i2 FILEβ specifies index barcodes associated with the-1and-2files. These get appended to READ1 and READ2 records in the barcode (BC) and quality (QT) tags.-iβ specifies that the Illumina CASAVA identifiers should be processed. This may set the READ1, READ2 and QCFAIL flags and add a barcode tag.-U,--UMIβ migrates the UMI sequence from the last read name component to the UMI bar code π₯--UMI-tag TAGβ specifies which aux tag to place the UMI barcode into. Default isRX.-N,--name2β assumes the read names are encoded in the SRA and ENA formats, where the first word is an automatically generated name with the second field being the original name. This option extracts that second field instead π--barcode-tag TAGβ changes the auxiliary tag used for barcode sequence. Defaults toBC.--quality-tag TAGβ changes the auxiliary tag used for barcode quality. Defaults toQT.-oFILEβ output toFILE. By default output gets written tostdout.--order TAGβ when outputting a SAM record, also outputs an integer tag containing the Nth record number. This may be useful if the data is to be sorted or collated in some manner and we want this to be reversible. In that case the tag may be used withsamtools sort -t TAGto regenerate the original input order π
β οΈ note: integer tags can only hold up to 2^32 record numbers (approximately 4 billion). Data sets with more records can switch to using a fixed-width string tag instead, with leading0s to ensure sort works. To do this, specifyTAG:LENGTH. E.g.--order rn:12will be able to sort up to 1 trillion records. fr fr, that's a lot of records π
-r RG_line,--rg-line RG_lineβ a complete@RGheader line may be specified, with or without the initial"@RG"component. If specified, this will also use the ID field fromRG_linein each SAM record's RG auxiliary tag.
If specified multiple times, this appends to the RG line, automatically adding tabs between invocations β¨
-R RG_ID,--rg RG_IDβ a shorter form of the option above, equivalent to--rg-line ID:RG_ID. If both are specified, then this option is ignored.-uβ output BAM or CRAM as uncompressed data.-T TAGLISTβ looks for any SAM-format auxiliary tags in the comment field of a fastq read name. These must match the<alpha-num><alpha-num>:<type>:<data>pattern as specified in the SAM specification.TAGLISTcan be blank or*to indicate all tags should be copied to the output, otherwise it's a comma-separated list of tag types to include, with all others being discarded π
π EXAMPLES π
Convert a single-ended fastq file to an unmapped CRAM. Both of these commands perform the same action.
samtools import -0 in.fastq -o out.cram
samtools import in.fastq > out.cram
Convert a pair of Illumina fastqs containing CASAVA identifiers to BAM, adding the barcode information to the BC auxiliary tag.
samtools import -i -1 in_1.fastq -2 in_2.fastq -o out.bam
samtools import -i in_[12].fastq > out.bam
Specify the read group. These commands are equivalent.
samtools import -r "$(echo -e 'ID:xyz\tPL:ILLUMINA')" in.fq
samtools import -r "$(echo -e '@RG\tID:xyz\tPL:ILLUMINA')" in.fq
samtools import -r ID:xyz -r PL:ILLUMINA in.fq
Create an unmapped BAM file from a set of 4 Illumina fastqs from bcf2fastq, consisting of two read and two index tags. The CASAVA identifier is used only for setting QC pass / failure status.
samtools import -i -1 R1.fq -2 R2.fq --i1 I1.fq --i2 I2.fq -o out.bam
Convert a pair of CASAVA barcoded fastq files to unmapped CRAM with an incremental record counter, then sort this by minimiser in order to reduce file space. The reversal process is also shown using samtools sort and samtools fastq π
samtools import -i in_1.fq in_2.fq --order ro -O bam,level=0 | \
samtools sort -@4 -M -o out.srt.cram -
samtools sort -@4 -O bam -u -t ro out.srt.cram | \
samtools fastq -1 out_1.fq -2 out_2.fq -i --index-format "i*i*"
π AUTHOR π
Written by James Bonfield of the Wellcome Sanger Institute. we stan π
π SEE ALSO π
samtools(1), samtools-fastq(1)
Samtools website: <http://www.htslib.org/>
and that's the whole page, bestie!! πβ¨ this wassamtools-1.24, dated 9 July 2026, and it's thesamtools-import(1)manual β go forth and convert those FASTQs, you absolute icon ππ¦π
π¦ where this page comes from
- epel 10: samtools 1.24-2.el10_3 Β· MIT
- nixpkgs unstable: samtools 1.24
- Copyright (C) 2020 Genome Research Ltd
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms