Hiho,
I just tried to reproduce your problem and everything worked fine!
I am not too good with perl regexps but I changed only things which connot
have any relation with your problem. Here is some modified
code:
#!/usr/bin/perl -w
#A program that accept an input file: Scorpion database from Gen Bank
#and will output the database in BioWare format
my $file1="$ARGV[0]"; #var to save the input database
my $counter=1;
open(INFO1,$file1) or die "Can't open $file1.\n";#open file1
foreach(<INFO1>)
{
if(/DATE\s*(.*)-(.*)-(.*)/){
print 'DATE'."\t".'"'."$1-$2-$3".'"'."\n";
}
elsif(/\s*\/intron=(.+)\n/) {
my $item;
my $local=$1;
$local =~ s/\"//g;
foreach $item (split('\;',$local)) {
$item = " - " if $item =~ " ";
print "Intron\t \{Translation%$item\}\n";
}
} #end elsif
elsif(/\s*\/exon=(.+)\n/) {
my $item;
my $local=$1;
$local =~ s/\"//g;
foreach $item (split('\;',$local)) {
$item = " - " if $item =~ " ";
print "Exon\t", " \{Translation\%","$item\}","\n";
}
}
}
The significant changes are
- Added a semicolon after my $file1="$ARGV[0]"
- Removed the circonflex in if(/^DATE\s*(.*)-(.*)-(.*)/)
- Added the if-statement to handle empty transaction-strings
Now I get the following output with your example
michael@trul:~/> perl prog.pl input
DATE "13-JUN-2000"
Exon {Translation%49-333}
Intron {Translation%1-48}
Intron {Translation%334-385}
DATE "14-JUN-2000"
Exon {Translation%1-120}
Intron {Translation% - }
So in my opinion everything works as desired.
Regards
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.