On Feb 4, Michael S. Robeson II said:

> >bob
>AGTGATGCCGACG
> >fred
>ACGCATATCGCAT
> >jon
>CAGTACGATTTATC

>R 1 20
>
>  A G U G A T G C C G A C G - - - - - - -       bob
>  A C G C A U A U C G C A U - - - - - - -       fred
>  C A G U A C G A U U U A U C - - - - - -       jon
>
>
>The "R 1" is static and should always appear. The "20" at the top of
>the new file should be a number defined by the user, that is they
>should be prompted for the length they wish the sequence to be. That is
>the total length of the sequence plus the added dashes could be 20 or
>3000 or whatever.  So, if they type 20 and there is only 10 letters in
>that row then the script should add 10 dashes to bring that total up to
>the 20 chosen by the user.

I'll provide one way to do this:

  # assuming $size has the number entered by the user

  while (<FILE>) {
    my ($name) = / >(.+)/;    # get the line name
    chomp(my $DNA = <FILE>);  # get the next line (the DNA)

    # add $size - length() dashes to the end of $DNA
    $DNA .= "-" x ($size - length $DNA);

    # print the DNA with spaces, then a tab, then the name
    print join(" ", split //, $DNA), "\t$name\n";
  }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to