This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract a particular region from a nucleotide contig?

Hi,

I have downloaded a contig from NCBI. It is around 100 kbp long and has a integrated prophage region. The prophage region is between 54501-90604 bp. How to extract only 54501-90604 bp from this contig?

Cheers

sequence assembly

3 answers

use samtools faidx to index and retrieve those coordinates

grep -v -E '^>|^$' input.fasta | tr -d '\n' | cut -c 54501-90604 | fold -w 60

The easiest (for me) would be:

from Bio import SeqIO

rec = SeqIO.read('/path/to/file', 'format')  # assuming only one sequence in the file
prophage = rec[54501:90604]

# write sequence out or do whatever analysis next.

You will need to double check the coordinates. Since python starts at 0, I think you may need to subtract 1 from each index.

Log in to answer this question.