[Bioperl-l] counting nucleotides in a sequence

Jason Stajich jason at cgt.mc.duke.edu
Tue Feb 18 22:37:49 EST 2003


yep - in fact code will actually fail if the seq is not divisible evenly
by $chunk.

One should probably change the loop conditional to
for( my $i = 1; $i+$chunk < $seq->length; $i+= $chunk) {
}

You'd need to be a little smarter about the code if you also wanted to
grab the nt counts from the last window if it was < $chunk.  Exercise left
to the reader =) ...


-jason

On Wed, 19 Feb 2003, Alan Christoffels wrote:

>
> Hi jason,
>
> > Not the fastest way to do it, but this code will get you the sequence
> > chunks of length 10.
> > Look at
> > Bio::Tools::SeqStats for an easy way to calculate the individual nt
> > frequencies (count_monomers).
> >
> > my $chunk = 10;
> > for( my $i = 1; $i < $seq->length; $i+= $chunk) {
> >  my $subseq = $seq->trunc($i,$i+$chunk-1);
> > }
>
> Would it be correct to assume that this code will not handle the last 5
> bases when the seqlength=35 and $i approaches 30.
>
> Alan
>
> >
> > -j
> > On Wed, 19 Feb 2003 parvesh at pacific.net.sg wrote:
> >
> > > Hello
> > > I am interested in calculating the nucleotides A,C, G and T
> > > in my sequence for every 10 nt window.
> >
> > > So I need to write a code that will scan the sequence for every 10 nts
> > > like 1-10,11-20. preferably i can then stack the result in arrays and
> > > write this array to file. Can someone help me to do this using bioperl
> > > code please ? Thanks in advance for your help!
> > >
> > > Best wishes
> > > Parvesh
> > >
> > > _______________________________________________
> > > Bioperl-l mailing list
> > > Bioperl-l at bioperl.org
> > > http://bioperl.org/mailman/listinfo/bioperl-l
> > >
> >
> > --
> > Jason Stajich
> > Duke University
> > jason at cgt.mc.duke.edu
> > _______________________________________________
> > Bioperl-l mailing list
> > Bioperl-l at bioperl.org
> > http://bioperl.org/mailman/listinfo/bioperl-l
> >
>
>

--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu


More information about the Bioperl-l mailing list