Answers.Body: <p>Standard approaches would be either <code>samtools idxstats</code> or <code>samtools view -H</code>, both of which will produce the exact same results. In fact, all methods will produce the exact same result, since contig length is set by the reference you align against.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T14:49:49.453Z
Answers.Text: Specifically, reference length is not "*computed*", it is *stored*. In theory an aligner could store anything in the contig length header records, but generally its the length, in characters, of the FASTA entry for the reference from the genome the reads were aligned to.
Answers.UserDisplayName: Ian Sudbery
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T17:53:46.963Z
Answers.Text: @IanSudbery I see your point. Finding the length of characters in the FASTA reference is somewhat of a "computation" though, right? Would "recorded" be a better way to describe it?
Answers.UserDisplayName: EB2127
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-02-06T11:18:04.657Z
Answers.LastActivityDate: 2018-02-06T11:18:04.657Z
Answers.UserDisplayName: Devon Ryan
Body: <p>What is the standard way to measure contig sequence lengths in a BAM? </p>
  
  <p>My understanding is that the community would use <code>samtools idxstats</code> to compute this information from the corresponding index file. </p>
  
  <p>Are there more precise/standard approaches? </p>
  
Tags: <samtools>
Title: What is the standard way to measure contig sequence lengths in a BAM?
ThreadText: # What is the standard way to measure contig sequence lengths in a BAM?
  
  (Asked by: username_0 on 2018-02-06)
  
  What is the standard way to measure contig sequence lengths in a BAM?
  
  My understanding is that the community would use `samtools idxstats` to compute this information from the corresponding index file.
  
  Are there more precise/standard approaches?
  
  **Tags:** samtools
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-02-06. Score: 4 | Accepted answer
  
  Standard approaches would be either `samtools idxstats` or `samtools view -H`, both of which will produce the exact same results. In fact, all methods will produce the exact same result, since contig length is set by the reference you align against.
  
  > **Comments:**
  > **username_2**: Specifically, reference length is not "*computed*", it is *stored*. In theory an aligner could store anything in the contig length header records, but generally its the length, in characters, of the FASTA entry for the reference from the genome the reads were aligned to.  
  > **username_0**: @username_2 I see your point. Finding the length of characters in the FASTA reference is somewhat of a "computation" though, right? Would "recorded" be a better way to describe it?  
  
  ---
  
  