On Fri, Jul 31, 2009 at 10:19, <[email protected]> wrote:
> This is what the file actually looks like. All fileds are
> separated by tabs
snip
The following script has visibly correct data and works. This points
to your data being the problem. Try this one-liner to see what you
data really looks like:
perl -nle 'print join ", ", map { "[$_]" } split /\t/' datafile
#!/usr/bin/perl
use strict;
use warnings;
my $fakefile = <<EOF;
HMU00030\t2522\t4840\t\tDNA gyrase subunit B
HMU00040\t4841\t5083\t\tputative membrane protein
HMU00050\t5080\t5739\tc\tputative periplasmic C39-family peptidase
HMU00060\t5739\t6549\tc\tputative inner membrane protein
EOF
open my $fh, "<", \$fakefile
or die "could note create a fake file: $!";
while(<$fh>){
my ($Gene, $Start, $Stop, $Strand, $Product) = split /\t/;
if ($Strand eq "c"){
print "$Gene\t-\t$Start\t$Stop\t$Product\n";
} else {
print "$Gene\t+\t$Start\t$Stop\t$Product\n";
}
}
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/