text: user16884: Good morning, I study bioinformatics and I need some help with a work. I have the NCBI accession numbers for the species I want for example: NC_037078.1 and I have the specific coordinates where I need to cut them to obtain the 16s gene but I don´t know how to do it. I'm using the language shell script. Is there some way to cut the genome into one specific region?
  
  user10775: If you know the coordinates, you could just use samtools faidx to extract the corresponding subsequence from the FASTA file(s). Regions can be specified on the command line with the format: RNAME[:STARTPOS[-ENDPOS]]. For example, to extract the first ten bases from chr1 in your reference FASTA file, you would use:
  samtools faidx ref.fasta chr1:1-10
  
  Or if you wanted the whole chromosome, you would use:
  samtools faidx ref.fasta chr1
  
  
  
  With regards to your specific example, you could try:
  samtools faidx NC_037078.1.fasta NC_037078.1:96630-98120
  
  Results:
  >NC_037078.1:96630-98120
  TCTCATGGAGAGTTCGATCCTGGCTCAGGATGAACGCTGGCGGCATGCTTAACACATGCA
  AGTCGGACGGGAAGTGGTGTTTCCAGTGGCGGACGGGTGAGTAACGCGTAAGAACCTGCC
  CTTGGGAGGGGAACAACAGCTGGAAACGGCTGCTAATACCCCGTAGGCTGAGGAGCAAAA
  GGAGGAATCCGCCCGAGGAGGGGCTTGCGTCTGATTAGCTAGTTGGTGAGGCAATAGCTT
  ACCAAGGCGATGATCAGTAGCTGGTCCGAGAGGATGATCAGCCACACTGGGACTGAGACA
  CGGCCCAGACTCCTACGGGAGGCAGCAGTGGGGAATTTTCCGCAATGGGCGAAAGCCTGA
  CGGAGCAATGCCGCGTGGAGGTAGAAGGCCCACGGGTCGTGAACTTCTTTTCCCGGAGAA
  GAAGCAATGACGGTATCTGGGGAATAAGCATCGGCTAACTCTGTGCCAGCAGCCGCGGTA
  AGACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTT
  TTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTACCAAGCT
  GGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAA
  AGAACACCAACGGCGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTA
  GGGGAGCGAATGGGATTAGATACCCCAGTAGTCCTAGCCGTAAACGATGGATACTGGGCG
  CTGTGCGTATCGACCCGTGCAGTGCTGTAGCTAACGCGTTAAGTATCCCGCCTGGGGAGT
  ACGTTCGCAAGAATGAAACTCAAAGGAATTGACGGGGGCCCGCACAAGCGGTGGAGCATG
  TGGTTTAATTCGATGCAAAGCGAAGAACCTTACCAGGGCTTGACATGCCGCGAATCCTTT
  TGAAAGAGAGGGGTGCCTTCGGGAACGCGGACACAGGTGGTGCATGGCTGTCGTCAGCTC
  GTGCCGTAAGGTGTTGGGTTAAGTCCCGCAACGAGCGCAACCCTCGTGTTTAGTTGCCAT
  CGTTGAATTTGGAACCCTGAACAGACTGCCGGTGATAAGCCGGAGGAAGGTGAGGATGAC
  GTCAAGTCATCATGCCCCTTATGCCCTGGGCGACACACGTGCTACAATGGCCGGGACAAA
  GGGTCGCGATCTCGCGAGGGTGAGCTAACCCCAAAAACCCGTCCTCAGTTCGGATTGCAG
  GCTGCAACTCGCCTGCATGAAGCCGGAATCGCTAGTAATCGCCGGTCAGCCATACGGCGG
  TGAATTCGTTCCCGGGCCTTGTACACACCGCCCGTCACACTATGGGAGCTGGCCATGCCC
  GAAGTCGTTACCTTAACCGCAAGGAGGGGGATGCCGAAGGCAGGGCTAGTGACTGGAGTG
  AAGTCGTAACAAGGTAGCCGTACTGGAAGGTGCGGCTGGATCACCTCCTTT
  
  Note that one or more regions may be specified on the command line and all position coordinates are 1-based. If the index file (i.e. <ref.fasta>.fai) doesn't exist, it will be created. If no regions are specified, samtools faidx will simply create the index file and exit. This is useful if you need to create the index prior to querying it. Only uncompressed FASTA files or FASTA files compressed with bgzip can be indexed.
  $ samtools faidx -h
  Usage: samtools faidx <file.fa|file.fa.gz> [<reg> [...]]
  Option: 
   -o, --output FILE        Write FASTA to file.
   -n, --length INT         Length of FASTA sequence line. [60]
   -c, --continue           Continue after trying to retrieve missing region.
   -r, --region-file FILE   File of regions.  Format is chr:from-to. One per line.
   -i, --reverse-complement Reverse complement sequences.
       --mark-strand TYPE   Add strand indicator to sequence name
                            TYPE = rc   for /rc on negative strand (default)
                                   no   for no strand indicator
                                   sign for (+) / (-)
                                   custom,<pos>,<neg> for custom indicator
       --fai-idx      FILE  name of the index file (default file.fa.fai).
       --gzi-idx      FILE  name of compressed file index (default file.fa.gz.gzi).
   -f, --fastq              File and index in FASTQ format.
   -h, --help               This message.
  
  
original_text: 16884: <p>Good morning, I study bioinformatics and I need some help with a work. I have the NCBI accession numbers for the species I want for example: NC_037078.1 and I have the specific coordinates where I need to cut them to obtain the 16s gene but I don´t know how to do it. I'm using the language shell script. Is there some way to cut the genome into one specific region?</p>
   10775: <p>If you know the coordinates, you could just use <a href="https://www.htslib.org/doc/samtools-faidx.html" rel="nofollow noreferrer"><code>samtools faidx</code></a> to extract the corresponding subsequence from the FASTA file(s). Regions can be specified on the command line with the format: <code>RNAME[:STARTPOS[-ENDPOS]]</code>. For example, to extract the first ten bases from <code>chr1</code> in your reference FASTA file, you would use:</p>
  <pre><code>samtools faidx ref.fasta chr1:1-10
  </code></pre>
  <p>Or if you wanted the whole chromosome, you would use:</p>
  <pre><code>samtools faidx ref.fasta chr1
  </code></pre>
  <hr />
  <hr />
  <p>With regards to your specific example, you could try:</p>
  <pre><code>samtools faidx NC_037078.1.fasta NC_037078.1:96630-98120
  </code></pre>
  <p>Results:</p>
  <pre><code>&gt;NC_037078.1:96630-98120
  TCTCATGGAGAGTTCGATCCTGGCTCAGGATGAACGCTGGCGGCATGCTTAACACATGCA
  AGTCGGACGGGAAGTGGTGTTTCCAGTGGCGGACGGGTGAGTAACGCGTAAGAACCTGCC
  CTTGGGAGGGGAACAACAGCTGGAAACGGCTGCTAATACCCCGTAGGCTGAGGAGCAAAA
  GGAGGAATCCGCCCGAGGAGGGGCTTGCGTCTGATTAGCTAGTTGGTGAGGCAATAGCTT
  ACCAAGGCGATGATCAGTAGCTGGTCCGAGAGGATGATCAGCCACACTGGGACTGAGACA
  CGGCCCAGACTCCTACGGGAGGCAGCAGTGGGGAATTTTCCGCAATGGGCGAAAGCCTGA
  CGGAGCAATGCCGCGTGGAGGTAGAAGGCCCACGGGTCGTGAACTTCTTTTCCCGGAGAA
  GAAGCAATGACGGTATCTGGGGAATAAGCATCGGCTAACTCTGTGCCAGCAGCCGCGGTA
  AGACAGAGGATGCAAGCGTTATCCGGAATGATTGGGCGTAAAGCGTCTGTAGGTGGCTTT
  TTAAGTCCGCCGTCAAATCCCAGGGCTCAACCCTGGACAGGCGGTGGAAACTACCAAGCT
  GGAGTACGGTAGGGGCAGAGGGAATTTCCGGTGGAGCGGTGAAATGCGTAGAGATCGGAA
  AGAACACCAACGGCGAAAGCACTCTGCTGGGCCGACACTGACACTGAGAGACGAAAGCTA
  GGGGAGCGAATGGGATTAGATACCCCAGTAGTCCTAGCCGTAAACGATGGATACTGGGCG
  CTGTGCGTATCGACCCGTGCAGTGCTGTAGCTAACGCGTTAAGTATCCCGCCTGGGGAGT
  ACGTTCGCAAGAATGAAACTCAAAGGAATTGACGGGGGCCCGCACAAGCGGTGGAGCATG
  TGGTTTAATTCGATGCAAAGCGAAGAACCTTACCAGGGCTTGACATGCCGCGAATCCTTT
  TGAAAGAGAGGGGTGCCTTCGGGAACGCGGACACAGGTGGTGCATGGCTGTCGTCAGCTC
  GTGCCGTAAGGTGTTGGGTTAAGTCCCGCAACGAGCGCAACCCTCGTGTTTAGTTGCCAT
  CGTTGAATTTGGAACCCTGAACAGACTGCCGGTGATAAGCCGGAGGAAGGTGAGGATGAC
  GTCAAGTCATCATGCCCCTTATGCCCTGGGCGACACACGTGCTACAATGGCCGGGACAAA
  GGGTCGCGATCTCGCGAGGGTGAGCTAACCCCAAAAACCCGTCCTCAGTTCGGATTGCAG
  GCTGCAACTCGCCTGCATGAAGCCGGAATCGCTAGTAATCGCCGGTCAGCCATACGGCGG
  TGAATTCGTTCCCGGGCCTTGTACACACCGCCCGTCACACTATGGGAGCTGGCCATGCCC
  GAAGTCGTTACCTTAACCGCAAGGAGGGGGATGCCGAAGGCAGGGCTAGTGACTGGAGTG
  AAGTCGTAACAAGGTAGCCGTACTGGAAGGTGCGGCTGGATCACCTCCTTT
  </code></pre>
  <p>Note that one or more regions may be specified on the command line and all position coordinates are 1-based. If the index file (i.e. <code>&lt;ref.fasta&gt;.fai</code>) doesn't exist, it will be created. If no regions are specified, <code>samtools faidx</code> will simply create the index file and exit. This is useful if you need to create the index prior to querying it. Only uncompressed FASTA files or FASTA files compressed with <a href="https://www.htslib.org/doc/bgzip.html" rel="nofollow noreferrer">bgzip</a> can be indexed.</p>
  <pre><code>$ samtools faidx -h
  Usage: samtools faidx &lt;file.fa|file.fa.gz&gt; [&lt;reg&gt; [...]]
  Option: 
   -o, --output FILE        Write FASTA to file.
   -n, --length INT         Length of FASTA sequence line. [60]
   -c, --continue           Continue after trying to retrieve missing region.
   -r, --region-file FILE   File of regions.  Format is chr:from-to. One per line.
   -i, --reverse-complement Reverse complement sequences.
       --mark-strand TYPE   Add strand indicator to sequence name
                            TYPE = rc   for /rc on negative strand (default)
                                   no   for no strand indicator
                                   sign for (+) / (-)
                                   custom,&lt;pos&gt;,&lt;neg&gt; for custom indicator
       --fai-idx      FILE  name of the index file (default file.fa.fai).
       --gzi-idx      FILE  name of compressed file index (default file.fa.gz.gzi).
   -f, --fastq              File and index in FASTQ format.
   -h, --help               This message.
  </code></pre>
  