This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython or Bioperl help

Hello all,

I am new to computational biology and NGS . As part of my work I have to use a code through which we can calculate chromosome size by analyzing genome fasta files. The program should take genome fasta file as input and store the sequence length in an array and then print out the sizes for each chromosome. anyone please help me on this

Thank you for your help :)

next-gen rna-seq biopython sequence

My best advice is to try it yourself and ask if you get stuck. Writing code is the only way to learn. The BioPerl HOWTOs are a good place to start and there are complete examples for doing things like getting sequence stats.

2 answers

Here is a biopython script to take FASTA format and print out header and the length of the sequence. Run like: python script.py file.fasta

import sys
from Bio import SeqIO

with open(sys.argv[1], 'rU') as input:
    SeqRecords = SeqIO.parse(input, 'fasta')
    for rec in SeqRecords:
        print "%s\t%I" % rec.id, len(rec.seq))

In this perl script there is a line my $sequence_length = length($sequence); , just write a line to print that. Your work will be done. you can find other scripts for Nucleotide sequence analysis as well in that repository

Log in to answer this question.