Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Hi, hopefully you are actually indenting your work and that it got unindented by not using code tags.
#! /usr/local/bin/perl -w use strict; open (INPUT, $ARGV[0]) or die "unable to open file";
This is precisely what the perl idiom while (<>){} is for
my $sequence; my $count =0; my $base = ("A"|"C"|"G"|"T");
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 @array; my $ideal = 250; while (<INPUT>) {
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 $/
$sequence = $_;
No need to save $_ unless intend to do something that will smash it. Which afact you arent.
@array = (); @array = split (/\n/, $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. :-)

Maybe this does what you want, or least points you in the right direction?

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 }
One of the cool things about the while (<>) idiom is that it will allow you to do this:
# 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
HTH

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found