Answers.Body: <p>You can use NCBI <a href="https://www.ncbi.nlm.nih.gov/books/NBK179288/" rel="nofollow noreferrer">EntrezDirect</a> to download data in GenBank format for a specific region of the sequence as follows:</p>
  <pre><code>efetch -db nuccore -id NC_000962.3 -format gb -seq_start 1 -seq_stop 99000 &gt; seq.gb
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-28T12:36:47.577Z
Answers.Text: The genome fragments from NCBI do not fit my purpose. The input file is obtained from another program and I need to split that file as mentioned in the question.
Answers.UserDisplayName: BhushanDhamale
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-28T12:05:13.113Z
Answers.LastActivityDate: 2021-01-28T12:05:13.113Z
Answers.UserDisplayName: vkkodali
Answers.Body: <p>I don't have time to give you a polished fully functional version but this will get you started. The next step will be a bit harder as you will need to capture the start of the first CDS in the chunk and end of the last CDS instead of just hardcoding as I have here.</p>
  <pre><code>fout = open('/path/first3.gbk','w')
  for record in SeqIO.parse('/path/NC_000962.3.final.gbk','genbank'):
      for i, feature in enumerate(record.features):
          new_record = record
          new_record.seq = new_record.seq[0:4437]
          new_record.features = new_record.features[:3]
          if i &gt; 2:
              SeqIO.write(new_record, fout, 'genbank')
              fout.close()
              break
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-01-28T22:50:40.050Z
Answers.LastActivityDate: 2021-01-28T23:23:58.257Z
Answers.LastEditDate: 2021-01-28T23:23:58.257Z
Answers.UserDisplayName: Liam McIntyre
Body: <p>I have a <a href="https://drive.google.com/file/d/18ImTLxSIv2o85TdwNcJOoQD64ibOmJUK/view?usp=sharing" rel="nofollow noreferrer">genbank file</a> that I have been trying to run in HMMER using the following command:</p>
  <pre><code>hmmscan --domtblout NC_000962.3.final.gbk.out -E 0.000001 prot_profile.hmm NC_000962.3.final.gbk
  </code></pre>
  <p>However, since the file is too big for HMMER, I get the following error:</p>
  <pre><code>Fatal exception (source file p7_pipeline.c, line 697): 
  Target sequence length &gt; 100K, over comparison pipeline limit. 
  (Did you mean to use nhmmer/nhmmscan?) 
  Aborted (core dumped)
  </code></pre>
  <p>I need to split this file into smaller files for the HMMER run. The problem is, I would need the <em>ORIGIN</em> field (containing the nucleotide sequence) at the bottom of the file split into relevant chunks into the subfile as well. This is where I am getting stuck.</p>
  <p>I have already looked at <em>GenBank Parser</em> and <em>seqretsplit</em> to no avail.</p>
  <p>I would greatly appreciate some help with this. Thank you.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-28T20:42:07.633Z
Comments.Text: Can do it with biopython
Comments.UserDisplayName: Liam McIntyre
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-01-28T20:45:28.367Z
Comments.Text: Could you please expand on your answer, Liam?
Comments.UserDisplayName: BhushanDhamale
Tags: <genbank><hmmer>
Title: Splitting a GenBank file into smaller files
ThreadText: # Splitting a GenBank file into smaller files
  
  (Asked by: username_0 on 2021-01-28)
  
  I have a [genbank file](https://drive.google.com/file/d/18ImTLxSIv2o85TdwNcJOoQD64ibOmJUK/view?usp=sharing) that I have been trying to run in HMMER using the following command:
  
  ```
  hmmscan --domtblout NC_000962.3.final.gbk.out -E 0.000001 prot_profile.hmm NC_000962.3.final.gbk
  
  ```
  
  However, since the file is too big for HMMER, I get the following error:
  
  ```
  Fatal exception (source file p7_pipeline.c, line 697): 
  Target sequence length > 100K, over comparison pipeline limit. 
  (Did you mean to use nhmmer/nhmmscan?) 
  Aborted (core dumped)
  
  ```
  
  I need to split this file into smaller files for the HMMER run. The problem is, I would need the *ORIGIN* field (containing the nucleotide sequence) at the bottom of the file split into relevant chunks into the subfile as well. This is where I am getting stuck.
  
  I have already looked at *GenBank Parser* and *seqretsplit* to no avail.
  
  I would greatly appreciate some help with this. Thank you.
  
  **Tags:** genbank, hmmer
  
  > **Comments:**
  > **username_1**: Can do it with biopython  
  > **username_0**: Could you please expand on your answer, username_1?  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2021-01-28. Score: 1
  
  You can use NCBI [EntrezDirect](https://www.ncbi.nlm.nih.gov/books/NBK179288/) to download data in GenBank format for a specific region of the sequence as follows:
  
  ```
  efetch -db nuccore -id NC_000962.3 -format gb -seq_start 1 -seq_stop 99000 > seq.gb
  
  ```
  
  > **Comments:**
  > **username_0**: The genome fragments from NCBI do not fit my purpose. The input file is obtained from another program and I need to split that file as mentioned in the question.  
  
  ---
  
  ### Answer by username_1 on 2021-01-28. Score: 1
  
  I don't have time to give you a polished fully functional version but this will get you started. The next step will be a bit harder as you will need to capture the start of the first CDS in the chunk and end of the last CDS instead of just hardcoding as I have here.
  
  ```
  fout = open('/path/first3.gbk','w')
  for record in SeqIO.parse('/path/NC_000962.3.final.gbk','genbank'):
      for i, feature in enumerate(record.features):
          new_record = record
          new_record.seq = new_record.seq[0:4437]
          new_record.features = new_record.features[:3]
          if i > 2:
              SeqIO.write(new_record, fout, 'genbank')
              fout.close()
              break
  
  ```
  
  
  ---
  
  