Answers.Body: <p>The error message is accurate as the downloaded fasta file got corrupted.</p>
  <p>Printing all the contigs, using the command below (the quotes around <code>&gt;</code> are important, without quotes you will erase your fasta!)</p>
  <pre class="lang-bash prettyprint-override"><code>grep &quot;&gt;&quot; /results/rr/study/hg38s/study252-P200_analysis/fus-analysis/1000G_NYGC/GRCh38_full_analysis_set_plus_decoy_hla.fa | less -S
  </code></pre>
  <p>returns:</p>
  <pre><code>&gt;chr20  AC:CM000682.2  gi:568336004  LN:64444167  rl:Chromosome  M5:b18e6c531b0bd70e949a7fc20859cb01  AS:GRCh38
  &gt;chr21  AC:CM000683.2  gi:568336003  LN:46709983  rl:Chromosome  M5:974dc7aec0b755b19f031418fdedf293  AS:GRCh38  hm:multiple
  &gt;chr22  AC:CM000684.2  gi:568336002  LN:50818468  rl:Chromosome  M5:ac37ec46683600f808cdd41eac1d55cd  AS:GRCh38  hm:multiple
  &gt;chrX  AC:CM000685.2  gi:568336001  LN:156040895  rl:Chromosome  M5:2b3a55ff7f58eb308420c8a9b11cac50  AS:GRCh38
  &gt;chrY  AC:CM000686.2  gi:568336000  LN:57227415  rl:Chromosome  M5:ce3e31103314a704255f3cd90369ecce  AS:GRCh38  hm:10001-2781479,56887903-57217415
  CATCTTGAATTAATTTTTGTGTAAGGTGTAAGGAAGGGATCC&lt;Error&gt;&lt;Code&gt;ConnectionClosedException&lt;/Code&gt;&lt;Message&gt;Premature end of Content-Length delimited message body (expected: 189,622,683; received: 26,672,030)&lt;/Message&gt;&lt;ErrorMessa&gt;
  &gt;chrM  AC:J01415.2  gi:113200490  LN:16569  rl:Mitochondrion  M5:c68f52674c9fb33aef52dcf399755519  AS:GRCh38  tp:circular
  &gt;chr1_KI270706v1_random  AC:KI270706.1  gi:568335410  LN:175055  rg:chr1  rl:unlocalized  M5:62def1a794b3e18192863d187af956e6  AS:GRCh38
  &gt;chr1_KI270707v1_random  AC:KI270707.1  gi:568335409  LN:32032  rg:chr1  rl:unlocalized  M5:78135804eb15220565483b7cdd02f3be  AS:GRCh38
  &gt;chr1_KI270708v1_random  AC:KI270708.1  gi:568335408  LN:127682  rg:chr1  rl:unlocalized  M5:1e95e047b98ed92148dd84d6c037158c  AS:GRCh38
  &gt;chr1_KI270709v1_random  AC:KI270709.1  gi:568335407  LN:66860  rg:chr1  rl:unlocalized  M5:4e2db2933ea96aee8dab54af60ecb37d  AS:GRCh38
  </code></pre>
  <p>Showing a download error (in this case) somewhere in chrY.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-27T14:36:37.233Z
Answers.Text: Thanks for posting the answer! Please remember to accept it so the question can be marked as answered (I know you can't do it immediately, that's why I'm leaving this as a reminder).
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-26T09:46:15.837Z
Answers.LastActivityDate: 2024-04-26T09:46:15.837Z
Answers.UserDisplayName: Wouter De Coster
Body: <p>I just downloaded a reference genome (using wget), and attempted to use it with samtools view. However, I received the following error:</p>
  <pre><code>[E::fai_build_core] Different line length in sequence 'chrY'
  [E::fai_path] Failed to build index file for reference file 'GRCh38_full_analysis_set_plus_decoy_hla.fa'
  [E::fai_build_core] Different line length in sequence 'chrY'
  [E::refs_load_fai] Failed to open reference file 'GRCh38_full_analysis_set_plus_decoy_hla.fa'
  [E::hts_open_format] Failed to open file &quot;ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR324/ERR3240208/HG00244.final.cram&quot; : No such file or directory
  samtools view: failed to open &quot;ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR324/ERR3240208/HG00244.final.cram&quot; for reading: No such file or directory
  </code></pre>
  <p>Just looking at the beginning of chrY in the fasta file does not look suspicious (grep chrY ).</p>
  
Tags: <fasta><samtools>
Title: Different line length in sequence 'chrY'
ThreadText: # Different line length in sequence 'chrY'
  
  (Asked by: username_0 on 2024-04-26)
  
  I just downloaded a reference genome (using wget), and attempted to use it with samtools view. However, I received the following error:
  
  ```
  [E::fai_build_core] Different line length in sequence 'chrY'
  [E::fai_path] Failed to build index file for reference file 'GRCh38_full_analysis_set_plus_decoy_hla.fa'
  [E::fai_build_core] Different line length in sequence 'chrY'
  [E::refs_load_fai] Failed to open reference file 'GRCh38_full_analysis_set_plus_decoy_hla.fa'
  [E::hts_open_format] Failed to open file "ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR324/ERR3240208/HG00244.final.cram" : No such file or directory
  samtools view: failed to open "ftp://ftp.sra.ebi.ac.uk/vol1/run/ERR324/ERR3240208/HG00244.final.cram" for reading: No such file or directory
  
  ```
  
  Just looking at the beginning of chrY in the fasta file does not look suspicious (grep chrY ).
  
  **Tags:** fasta, samtools
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-04-26. Score: 5 | Accepted answer
  
  The error message is accurate as the downloaded fasta file got corrupted.
  
  Printing all the contigs, using the command below (the quotes around `>` are important, without quotes you will erase your fasta!)
  
  ```bash
  grep ">" /results/rr/study/hg38s/study252-P200_analysis/fus-analysis/1000G_NYGC/GRCh38_full_analysis_set_plus_decoy_hla.fa | less -S
  
  ```
  
  returns:
  
  ```
  >chr20  AC:CM000682.2  gi:568336004  LN:64444167  rl:Chromosome  M5:b18e6c531b0bd70e949a7fc20859cb01  AS:GRCh38
  >chr21  AC:CM000683.2  gi:568336003  LN:46709983  rl:Chromosome  M5:974dc7aec0b755b19f031418fdedf293  AS:GRCh38  hm:multiple
  >chr22  AC:CM000684.2  gi:568336002  LN:50818468  rl:Chromosome  M5:ac37ec46683600f808cdd41eac1d55cd  AS:GRCh38  hm:multiple
  >chrX  AC:CM000685.2  gi:568336001  LN:156040895  rl:Chromosome  M5:2b3a55ff7f58eb308420c8a9b11cac50  AS:GRCh38
  >chrY  AC:CM000686.2  gi:568336000  LN:57227415  rl:Chromosome  M5:ce3e31103314a704255f3cd90369ecce  AS:GRCh38  hm:10001-2781479,56887903-57217415
  CATCTTGAATTAATTTTTGTGTAAGGTGTAAGGAAGGGATCC<Error><Code>ConnectionClosedException</Code><Message>Premature end of Content-Length delimited message body (expected: 189,622,683; received: 26,672,030)</Message><ErrorMessa>
  >chrM  AC:J01415.2  gi:113200490  LN:16569  rl:Mitochondrion  M5:c68f52674c9fb33aef52dcf399755519  AS:GRCh38  tp:circular
  >chr1_KI270706v1_random  AC:KI270706.1  gi:568335410  LN:175055  rg:chr1  rl:unlocalized  M5:62def1a794b3e18192863d187af956e6  AS:GRCh38
  >chr1_KI270707v1_random  AC:KI270707.1  gi:568335409  LN:32032  rg:chr1  rl:unlocalized  M5:78135804eb15220565483b7cdd02f3be  AS:GRCh38
  >chr1_KI270708v1_random  AC:KI270708.1  gi:568335408  LN:127682  rg:chr1  rl:unlocalized  M5:1e95e047b98ed92148dd84d6c037158c  AS:GRCh38
  >chr1_KI270709v1_random  AC:KI270709.1  gi:568335407  LN:66860  rg:chr1  rl:unlocalized  M5:4e2db2933ea96aee8dab54af60ecb37d  AS:GRCh38
  
  ```
  
  Showing a download error (in this case) somewhere in chrY.
  
  > **Comments:**
  > **username_1**: Thanks for posting the answer! Please remember to accept it so the question can be marked as answered (I know you can't do it immediately, that's why I'm leaving this as a reminder).  
  
  ---
  
  