Hi Furor, good luck with your research!
As a fellow biologist working with Perl, I highly recommend having a few ready modules for reading and writing Fasta files. It makes everything so much easier
You can find some great stuff in CPAN, but also if you need simple things it is good exercise to write it yourself.
Here is a short module that reads Fasta files into a hash that might come in handy:
package fasta_utils; use Exporter 'import'; @EXPORT_OK = qw(fasta2hash); use strict; use warnings; use lib '/cs/prt/mrguy/lib'; ##Reading the fasta formats of the file into hash sub fasta2hash { my ($file) = @_; print "file = $file\n"; my $seq_ref = {}; open IN, $file; my ($sequence,$id); while (my $line = <IN>){ if ($line =~/^\s*$/){ next; } if ($line =~ /^>(.*?)$/){ if ($id){ $seq_ref->{$id} = $sequence; } $id = $1; $sequence = ""; } else { chomp $line; $line =~ s/\s//g; $sequence .= $line; } } ##Putting in the last sequence if ($id){ $seq_ref->{$id} = $sequence; } return $seq_ref; } 1;
Hopes this helps in the future
Mr Guy

In reply to Re^4: remove part of string (DNA) by mrguy123
in thread remove part of string (DNA) by Furor

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.