text: user15521: I have a set of 4 .bam files containing the exome of an individual, around 400 MB each. I used samtools to generate a 2.4 GB .sam file out of one of the .bam files, and I found it contains lines with 101 base sequences but seemingly no RNAME or POS information on them. The first columns of the first lines in the read like this (I won't include here the SEQ, QUAL and optional fields):
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:18818    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:18818    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:32033    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:32033    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:12712    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:12712    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:21261    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:21261    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:34882    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:34882    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:07764    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:07764    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:11569    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:11569    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:26537    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:26537    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:21010    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:21010    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:27085    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:27085    141 *   0   0   *   *   0   0
  
  Most fields are nullified. As far as I can understand, subsequent lines with the 77 and 141 flags form corresponding pairs of bases and the QNAME field first element is an individual identifier, as it won't change through the head and tail of the file. Same goes for the second element (1). The last three elements change and might hold the information I need, but I'm not sure how to read them.
  What I want to do is to map bases to SNPs (or a nucleotide identifier like NC_000006.11).
  I have no real experience with bioinformatics besides enriching a file from MyHeritage (which contains around 609,000 base pairs with a corresponding rSNP number and chromossome) and crossed it with a reference human genome database I downloaded from NBCI. As it's a personal project, I somewhat validated the final result by correctly spotting a few known mutations/polymorphisms for that individual tested through usual lab tests, like the one output by the code I've wrote:
   RS1799945 (Chromosome 6 ): CG (NC_000006.11:g.26091179C>G, snv), https://www.ncbi.nlm.nih.gov/snp/rs1799945
            Reference Allele: C
                   Frequency:  9.6% (0.09631744626441) (~ 1:10)
                Loci (Genes): HFE  (homeostatic iron regulator)
                            : LOC108783645  (HFE antisense RNA)
          Detected Mutations: c.187C>G
               Variation URL: https://www.ncbi.nlm.nih.gov/clinvar/variation/10/
                    Diseases: not provided (conflicting-interpretations-of-pathogenicity), None (other), Hereditary hemochromatosis (pathogenic), Cystic fibrosis (risk-factor), Alzheimer disease (pathogenic), Familial porphyria cutanea tarda (None), Hemochromatosis type 1 (None), Microvascular complications of diabetes 7 (None), Transferrin serum leve, Microvascular complications of diabetes 7 (risk-factor), Hemochromatosis type 1 (pathogenic), Hemochromatosis type 2 (pathogenic)
                      PubMed: https://www.ncbi.nlm.nih.gov/pubmed/8696333, https://www.ncbi.nlm.nih.gov/pubmed/8896550, https://www.ncbi.nlm.nih.gov/pubmed/8943161, https://www.ncbi.nlm.nih.gov/pubmed/9106528, https://www.ncbi.nlm.nih.gov/pubmed/9326341, https://www.ncbi.nlm.nih.gov/pubmed/9462220, https://www.ncbi.nlm.nih.gov/pubmed/10673304, https://www.ncbi.nlm.nih.gov/pubmed/11358905, https://www.ncbi.nlm.nih.gov/pubmed/11423500, https://www.ncbi.nlm.nih.gov/pubmed/11812557, https://www.ncbi.nlm.nih.gov/pubmed/11874997, https://www.ncbi.nlm.nih.gov/pubmed/11904676, https://www.ncbi.nlm.nih.gov/pubmed/12429850, https://www.ncbi.nlm.nih.gov/pubmed/14673107, https://www.ncbi.nlm.nih.gov/pubmed/15347835, https://www.ncbi.nlm.nih.gov/pubmed/15858186, https://www.ncbi.nlm.nih.gov/pubmed/18194558, https://www.ncbi.nlm.nih.gov/pubmed/18199861, https://www.ncbi.nlm.nih.gov/pubmed/18566337, https://www.ncbi.nlm.nih.gov/pubmed/18603647, https://www.ncbi.nlm.nih.gov/pubmed/18795173, https://www.ncbi.nlm.nih.gov/pubmed/19084217, https://www.ncbi.nlm.nih.gov/pubmed/19159930, https://www.ncbi.nlm.nih.gov/pubmed/19165391, https://www.ncbi.nlm.nih.gov/pubmed/19237423, https://www.ncbi.nlm.nih.gov/pubmed/19401444, https://www.ncbi.nlm.nih.gov/pubmed/19554541, https://www.ncbi.nlm.nih.gov/pubmed/19862010, https://www.ncbi.nlm.nih.gov/pubmed/19879291, https://www.ncbi.nlm.nih.gov/pubmed/19884647, https://www.ncbi.nlm.nih.gov/pubmed/20110814, https://www.ncbi.nlm.nih.gov/pubmed/20301613, https://www.ncbi.nlm.nih.gov/pubmed/20435227, https://www.ncbi.nlm.nih.gov/pubmed/20556870, https://www.ncbi.nlm.nih.gov/pubmed/20659343, https://www.ncbi.nlm.nih.gov/pubmed/20846924, https://www.ncbi.nlm.nih.gov/pubmed/20876667, https://www.ncbi.nlm.nih.gov/pubmed/21138591, https://www.ncbi.nlm.nih.gov/pubmed/21149283, https://www.ncbi.nlm.nih.gov/pubmed/21208937, https://www.ncbi.nlm.nih.gov/pubmed/21540342, https://www.ncbi.nlm.nih.gov/pubmed/21553046, https://www.ncbi.nlm.nih.gov/pubmed/21679129, https://www.ncbi.nlm.nih.gov/pubmed/21909115, https://www.ncbi.nlm.nih.gov/pubmed/21978626, https://www.ncbi.nlm.nih.gov/pubmed/22074419, https://www.ncbi.nlm.nih.gov/pubmed/22100073, https://www.ncbi.nlm.nih.gov/pubmed/22125427, https://www.ncbi.nlm.nih.gov/pubmed/22232660, https://www.ncbi.nlm.nih.gov/pubmed/22408404, https://www.ncbi.nlm.nih.gov/pubmed/22611049, https://www.ncbi.nlm.nih.gov/pubmed/22735619, https://www.ncbi.nlm.nih.gov/pubmed/22815867, https://www.ncbi.nlm.nih.gov/pubmed/23389292, https://www.ncbi.nlm.nih.gov/pubmed/23446634, https://www.ncbi.nlm.nih.gov/pubmed/23792061, https://www.ncbi.nlm.nih.gov/pubmed/23935582, https://www.ncbi.nlm.nih.gov/pubmed/23996192, https://www.ncbi.nlm.nih.gov/pubmed/24033266, https://www.ncbi.nlm.nih.gov/pubmed/24121126, https://www.ncbi.nlm.nih.gov/pubmed/24398642, https://www.ncbi.nlm.nih.gov/pubmed/24755831, https://www.ncbi.nlm.nih.gov/pubmed/24798971, https://www.ncbi.nlm.nih.gov/pubmed/24825461, https://www.ncbi.nlm.nih.gov/pubmed/25071582, https://www.ncbi.nlm.nih.gov/pubmed/25112650, https://www.ncbi.nlm.nih.gov/pubmed/25287020, https://www.ncbi.nlm.nih.gov/pubmed/25741868, https://www.ncbi.nlm.nih.gov/pubmed/26024779, https://www.ncbi.nlm.nih.gov/pubmed/26025379, https://www.ncbi.nlm.nih.gov/pubmed/26159428, https://www.ncbi.nlm.nih.gov/pubmed/26365338, https://www.ncbi.nlm.nih.gov/pubmed/26416403, https://www.ncbi.nlm.nih.gov/pubmed/26597663, https://www.ncbi.nlm.nih.gov/pubmed/26695521, https://www.ncbi.nlm.nih.gov/pubmed/26716680, https://www.ncbi.nlm.nih.gov/pubmed/26833210, https://www.ncbi.nlm.nih.gov/pubmed/27221532, https://www.ncbi.nlm.nih.gov/pubmed/27255824, https://www.ncbi.nlm.nih.gov/pubmed/27280446, https://www.ncbi.nlm.nih.gov/pubmed/27317329, https://www.ncbi.nlm.nih.gov/pubmed/27437086, https://www.ncbi.nlm.nih.gov/pubmed/27547017, https://www.ncbi.nlm.nih.gov/pubmed/27584680, https://www.ncbi.nlm.nih.gov/pubmed/27657935, https://www.ncbi.nlm.nih.gov/pubmed/27661980, https://www.ncbi.nlm.nih.gov/pubmed/28151915, https://www.ncbi.nlm.nih.gov/pubmed/28684612, https://www.ncbi.nlm.nih.gov/pubmed/28820869, https://www.ncbi.nlm.nih.gov/pubmed/29167213, https://www.ncbi.nlm.nih.gov/pubmed/29201641, https://www.ncbi.nlm.nih.gov/pubmed/30409984, https://www.ncbi.nlm.nih.gov/pubmed/30536387, https://www.ncbi.nlm.nih.gov/pubmed/30798813, https://www.ncbi.nlm.nih.gov/pubmed/31220083, https://www.ncbi.nlm.nih.gov/pubmed/31226389, https://www.ncbi.nlm.nih.gov/pubmed/31469255, https://www.ncbi.nlm.nih.gov/pubmed/31970519
               Polymorphisms: c.118=, c.187=, c.118C>G, c.187C>G, g.8671=, g.8671C>G, g.26090951=, g.26091179=, g.26090951C>G, g.26091179C>G, p.His40=, p.His63=, p.His40Asp, p.His63Asp, n.84=, n.281=, n.309=, n.84G>C, n.281C>G, n.309C>G
       Clinical Significance: RCV000000026.18, RCV000000027.5, RCV000175607.6, RCV000394716.6, RCV000763144.1, RCV000844708.1, RCV000991133.1
                        HGVS:
  
  This question was also asked on Reddit
  
  user73: These lines (with no REF or POS) are unmapped reads. If those lines are the entirety of the BAM file, then it is simply another file format to store the raw sequenced reads (as an alternative to FASTQ files). It's somewhat common for BAM files to include all reads, with mapped reads sorted by chromosome and position at the start, and unmapped reads appearing at the end of the file. This means that only the BAM file needs to be transferred and stored, rather than a BAM file and a separate 'unmapped' file (which can change size/content depending on the reference genome and mapper used).
  FWIW, the lines of a BAM file can be viewed using samtools view; there's no need to convert to SAM first:
  samtools view -h input.bam | less
  
  If you only want to look at the unmapped reads, then you can filter for inclusion using the read flag 4:
  samtools view -f 0x04 -h input.bam | less
  
  If you want to exclude unmapped reads, you can filter that flag for exclusion (capital F instead of lower-case f):
  samtools view -F 0x04 -h input.bam | less
  
  
original_text: 15521: <p>I have a set of 4 .bam files containing the exome of an individual, around 400 MB each. I used samtools to generate a 2.4 GB .sam file out of one of the .bam files, and I found it contains lines with 101 base sequences but seemingly no RNAME or POS information on them. The first columns of the first lines in the read like this (I won't include here the SEQ, QUAL and optional fields):</p>
  <pre><code>210713_A00776_0149_AHCN5JDSX2:1:1101:10004:18818    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:18818    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:32033    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10004:32033    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:12712    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:12712    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:21261    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:21261    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:34882    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:34882    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:07764    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10022:07764    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:11569    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:11569    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:26537    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10031:26537    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:21010    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:21010    141 *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:27085    77  *   0   0   *   *   0   0
  210713_A00776_0149_AHCN5JDSX2:1:1101:10041:27085    141 *   0   0   *   *   0   0
  </code></pre>
  <p>Most fields are nullified. As far as I can understand, subsequent lines with the 77 and 141 flags form corresponding pairs of bases and the QNAME field first element is an individual identifier, as it won't change through the head and tail of the file. Same goes for the second element (1). The last three elements change and might hold the information I need, but I'm not sure how to read them.</p>
  <p><strong>What I want to do is to map bases to SNPs (or a nucleotide identifier like NC_000006.11).</strong></p>
  <p>I have no real experience with bioinformatics besides enriching a file from MyHeritage (which contains around 609,000 base pairs with a corresponding rSNP number and chromossome) and crossed it with a reference human genome database I downloaded from NBCI. As it's a personal project, I <em>somewhat</em> validated the final result by correctly spotting a few known mutations/polymorphisms for that individual tested through usual lab tests, like the one output by the code I've wrote:</p>
  <pre><code> RS1799945 (Chromosome 6 ): CG (NC_000006.11:g.26091179C&gt;G, snv), https://www.ncbi.nlm.nih.gov/snp/rs1799945
            Reference Allele: C
                   Frequency:  9.6% (0.09631744626441) (~ 1:10)
                Loci (Genes): HFE  (homeostatic iron regulator)
                            : LOC108783645  (HFE antisense RNA)
          Detected Mutations: c.187C&gt;G
               Variation URL: https://www.ncbi.nlm.nih.gov/clinvar/variation/10/
                    Diseases: not provided (conflicting-interpretations-of-pathogenicity), None (other), Hereditary hemochromatosis (pathogenic), Cystic fibrosis (risk-factor), Alzheimer disease (pathogenic), Familial porphyria cutanea tarda (None), Hemochromatosis type 1 (None), Microvascular complications of diabetes 7 (None), Transferrin serum leve, Microvascular complications of diabetes 7 (risk-factor), Hemochromatosis type 1 (pathogenic), Hemochromatosis type 2 (pathogenic)
                      PubMed: https://www.ncbi.nlm.nih.gov/pubmed/8696333, https://www.ncbi.nlm.nih.gov/pubmed/8896550, https://www.ncbi.nlm.nih.gov/pubmed/8943161, https://www.ncbi.nlm.nih.gov/pubmed/9106528, https://www.ncbi.nlm.nih.gov/pubmed/9326341, https://www.ncbi.nlm.nih.gov/pubmed/9462220, https://www.ncbi.nlm.nih.gov/pubmed/10673304, https://www.ncbi.nlm.nih.gov/pubmed/11358905, https://www.ncbi.nlm.nih.gov/pubmed/11423500, https://www.ncbi.nlm.nih.gov/pubmed/11812557, https://www.ncbi.nlm.nih.gov/pubmed/11874997, https://www.ncbi.nlm.nih.gov/pubmed/11904676, https://www.ncbi.nlm.nih.gov/pubmed/12429850, https://www.ncbi.nlm.nih.gov/pubmed/14673107, https://www.ncbi.nlm.nih.gov/pubmed/15347835, https://www.ncbi.nlm.nih.gov/pubmed/15858186, https://www.ncbi.nlm.nih.gov/pubmed/18194558, https://www.ncbi.nlm.nih.gov/pubmed/18199861, https://www.ncbi.nlm.nih.gov/pubmed/18566337, https://www.ncbi.nlm.nih.gov/pubmed/18603647, https://www.ncbi.nlm.nih.gov/pubmed/18795173, https://www.ncbi.nlm.nih.gov/pubmed/19084217, https://www.ncbi.nlm.nih.gov/pubmed/19159930, https://www.ncbi.nlm.nih.gov/pubmed/19165391, https://www.ncbi.nlm.nih.gov/pubmed/19237423, https://www.ncbi.nlm.nih.gov/pubmed/19401444, https://www.ncbi.nlm.nih.gov/pubmed/19554541, https://www.ncbi.nlm.nih.gov/pubmed/19862010, https://www.ncbi.nlm.nih.gov/pubmed/19879291, https://www.ncbi.nlm.nih.gov/pubmed/19884647, https://www.ncbi.nlm.nih.gov/pubmed/20110814, https://www.ncbi.nlm.nih.gov/pubmed/20301613, https://www.ncbi.nlm.nih.gov/pubmed/20435227, https://www.ncbi.nlm.nih.gov/pubmed/20556870, https://www.ncbi.nlm.nih.gov/pubmed/20659343, https://www.ncbi.nlm.nih.gov/pubmed/20846924, https://www.ncbi.nlm.nih.gov/pubmed/20876667, https://www.ncbi.nlm.nih.gov/pubmed/21138591, https://www.ncbi.nlm.nih.gov/pubmed/21149283, https://www.ncbi.nlm.nih.gov/pubmed/21208937, https://www.ncbi.nlm.nih.gov/pubmed/21540342, https://www.ncbi.nlm.nih.gov/pubmed/21553046, https://www.ncbi.nlm.nih.gov/pubmed/21679129, https://www.ncbi.nlm.nih.gov/pubmed/21909115, https://www.ncbi.nlm.nih.gov/pubmed/21978626, https://www.ncbi.nlm.nih.gov/pubmed/22074419, https://www.ncbi.nlm.nih.gov/pubmed/22100073, https://www.ncbi.nlm.nih.gov/pubmed/22125427, https://www.ncbi.nlm.nih.gov/pubmed/22232660, https://www.ncbi.nlm.nih.gov/pubmed/22408404, https://www.ncbi.nlm.nih.gov/pubmed/22611049, https://www.ncbi.nlm.nih.gov/pubmed/22735619, https://www.ncbi.nlm.nih.gov/pubmed/22815867, https://www.ncbi.nlm.nih.gov/pubmed/23389292, https://www.ncbi.nlm.nih.gov/pubmed/23446634, https://www.ncbi.nlm.nih.gov/pubmed/23792061, https://www.ncbi.nlm.nih.gov/pubmed/23935582, https://www.ncbi.nlm.nih.gov/pubmed/23996192, https://www.ncbi.nlm.nih.gov/pubmed/24033266, https://www.ncbi.nlm.nih.gov/pubmed/24121126, https://www.ncbi.nlm.nih.gov/pubmed/24398642, https://www.ncbi.nlm.nih.gov/pubmed/24755831, https://www.ncbi.nlm.nih.gov/pubmed/24798971, https://www.ncbi.nlm.nih.gov/pubmed/24825461, https://www.ncbi.nlm.nih.gov/pubmed/25071582, https://www.ncbi.nlm.nih.gov/pubmed/25112650, https://www.ncbi.nlm.nih.gov/pubmed/25287020, https://www.ncbi.nlm.nih.gov/pubmed/25741868, https://www.ncbi.nlm.nih.gov/pubmed/26024779, https://www.ncbi.nlm.nih.gov/pubmed/26025379, https://www.ncbi.nlm.nih.gov/pubmed/26159428, https://www.ncbi.nlm.nih.gov/pubmed/26365338, https://www.ncbi.nlm.nih.gov/pubmed/26416403, https://www.ncbi.nlm.nih.gov/pubmed/26597663, https://www.ncbi.nlm.nih.gov/pubmed/26695521, https://www.ncbi.nlm.nih.gov/pubmed/26716680, https://www.ncbi.nlm.nih.gov/pubmed/26833210, https://www.ncbi.nlm.nih.gov/pubmed/27221532, https://www.ncbi.nlm.nih.gov/pubmed/27255824, https://www.ncbi.nlm.nih.gov/pubmed/27280446, https://www.ncbi.nlm.nih.gov/pubmed/27317329, https://www.ncbi.nlm.nih.gov/pubmed/27437086, https://www.ncbi.nlm.nih.gov/pubmed/27547017, https://www.ncbi.nlm.nih.gov/pubmed/27584680, https://www.ncbi.nlm.nih.gov/pubmed/27657935, https://www.ncbi.nlm.nih.gov/pubmed/27661980, https://www.ncbi.nlm.nih.gov/pubmed/28151915, https://www.ncbi.nlm.nih.gov/pubmed/28684612, https://www.ncbi.nlm.nih.gov/pubmed/28820869, https://www.ncbi.nlm.nih.gov/pubmed/29167213, https://www.ncbi.nlm.nih.gov/pubmed/29201641, https://www.ncbi.nlm.nih.gov/pubmed/30409984, https://www.ncbi.nlm.nih.gov/pubmed/30536387, https://www.ncbi.nlm.nih.gov/pubmed/30798813, https://www.ncbi.nlm.nih.gov/pubmed/31220083, https://www.ncbi.nlm.nih.gov/pubmed/31226389, https://www.ncbi.nlm.nih.gov/pubmed/31469255, https://www.ncbi.nlm.nih.gov/pubmed/31970519
               Polymorphisms: c.118=, c.187=, c.118C&gt;G, c.187C&gt;G, g.8671=, g.8671C&gt;G, g.26090951=, g.26091179=, g.26090951C&gt;G, g.26091179C&gt;G, p.His40=, p.His63=, p.His40Asp, p.His63Asp, n.84=, n.281=, n.309=, n.84G&gt;C, n.281C&gt;G, n.309C&gt;G
       Clinical Significance: RCV000000026.18, RCV000000027.5, RCV000175607.6, RCV000394716.6, RCV000763144.1, RCV000844708.1, RCV000991133.1
                        HGVS:
  </code></pre>
  <p><em>This question was also asked on <a href="https://www.reddit.com/r/bioinformatics/comments/uuuyqx/bam_file_and_no_rname_or_pos_information/" rel="nofollow noreferrer">Reddit</a></em></p>
   73: <p>These lines (with no REF or POS) are unmapped reads. If those lines are the entirety of the BAM file, then it is simply another file format to store the raw sequenced reads (as an alternative to FASTQ files). It's somewhat common for BAM files to include <em>all</em> reads, with mapped reads sorted by chromosome and position at the start, and unmapped reads appearing at the end of the file. This means that only the BAM file needs to be transferred and stored, rather than a BAM file and a separate 'unmapped' file (which can change size/content depending on the reference genome and mapper used).</p>
  <p>FWIW, the lines of a BAM file can be viewed using <code>samtools view</code>; there's no need to convert to SAM first:</p>
  <pre><code>samtools view -h input.bam | less
  </code></pre>
  <p>If you only want to look at the unmapped reads, then you can filter for inclusion using the read flag 4:</p>
  <pre><code>samtools view -f 0x04 -h input.bam | less
  </code></pre>
  <p>If you want to <em>exclude</em> unmapped reads, you can filter that flag for exclusion (capital <code>F</code> instead of lower-case <code>f</code>):</p>
  <pre><code>samtools view -F 0x04 -h input.bam | less
  </code></pre>
  