- 论坛徽章:
- 0
|
是你程序的问题
#!/usr/bin/perl
use strict;
use warnings;
my $infile = 'infile.txt';
open IN, "< $infile"
or die "$infile: $!";
while (<IN>){
chomp;
next if $. == 1;
my $chro = (split/\t/)[5];
my $chrfile = "chr/ref_chr" . $chro . ".fa";
#
my $ctg = 'test';
#
my $seq = get_seq($chrfile, $ctg);
print "$seq\n";
}
sub get_seq{
my $chrfile = shift;
my $ctg = shift;
my $seq;
#
$chrfile = 'chrfile.txt';
#
open CHRO, "< $chrfile"
or die "$chrfile: $!";
while (<CHRO>){
chomp;
if (/^>/){
my $ctg_in = (split/\|/)[3];
$ctg_in =~ s/\..*$//;
next unless $ctg_in eq $ctg;
$seq = $_;
last;
}
}
return $seq;
} |
- infile.txt
- t h h h h h h h
- h h h h h h h h
- h h h h h h h h
- h h h h h h h h
- chrfile.txt
- =
- =
- =
- =
- >h|test|test|test|test|test|test
- >perl -w Perl-1.pl
- >h|test|test|test|test|test|test
- >h|test|test|test|test|test|test
- >h|test|test|test|test|test|test
- >Exit code: 0
复制代码
[ 本帖最后由 cobrawgl 于 2008-5-8 10:15 编辑 ] |
|