Hi guys,
I am just learning perl (my 1st computer language) and am having some trouble with a simple script.
I am trying to split a large genbank file into individual sequence files. The individual sequence files need to look like this...
>"accession #"_"biotype"<br> ^^<br> "sequence"<br> <br>
and the name of these files should be
"accession#_biotype.seq"

Here is my script...
use strict; use warnings; # Constants my $genfile = "c:\bemisia_coi.gb"; my $outfile = "$accession_$biotype"; my ($OUT, $IN); my $line; print "Input: $genfile\n"; open($IN, "$genfile") or die "cannot open $genfile\n"; while ($line = <$IN>) { $line = lc $line; #case insensitive my @line = split(/\///,$line); foreach my $i (0..$#line) { my $accession = "/locus\s*([a-z]{8})"; my $biotype = "/biotype: ([a-z]{1})"; my $sequence = "/origin(\*+)\//\"; $sequence =~ s/\s//g; #Removing spaces $sequence =~ s/\d//g; #Removing numbers open($OUT, '>' "$outfile") or die "cannot open $outfile \n"; print "Printing to $outfile \n"; print($OUT ">$accession_$biotype/n^^/n$sequence"); } }
Im getting tons of error that I think have to deal with local/global variables but I can't figure out, so any help is greatly appreciated!!!

In reply to Spltting Genbank File by perl_n00b

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.