This is precisely what the perl idiom while (<>){} is for#! /usr/local/bin/perl -w use strict; open (INPUT, $ARGV[0]) or die "unable to open file";
This probably doesnt do what you want. $base ends up being the binary or of the string A C G and T. Which happens to be "W". :-)my $sequence; my $count =0; my $base = ("A"|"C"|"G"|"T");
As i said before the while loop can be rewritten much cleaner. Also you are reading in a line at a time because you havent messed with $/my @array; my $ideal = 250; while (<INPUT>) {
No need to save $_ unless intend to do something that will smash it. Which afact you arent.$sequence = $_;
You read in a line, and then you split by \n. That wont help as there will only be 1 (or 0) but not more. So everything from there isnt going to go well. :-)@array = (); @array = split (/\n/, $sequence);
Maybe this does what you want, or least points you in the right direction?
One of the cool things about the while (<>) idiom is that it will allow you to do this:while (<>) { chomp; # lose potential newlines at the end. (only needed for portab +ility) print $_,"\n" if length $_ > 250; # print out any sequence longer t +han 250chars }
HTH# find every line over 250 chars from three different files, print the +m to STDOUT over_250 file.1 file.2 file.3 # find lines over 250 chars from STDIN over_250 <file.1
Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.
In reply to Re: simple but stuck
by demerphq
in thread Base sequence length in fasta format file
by lolly
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |