忽略 perl 中带有 ## 的前两行

  • 本文关键字:两行 perl 忽略 perl
  • 更新时间 :
  • 英文 :


all.

我是编程的新手,尤其是在perl中。我想跳过数据集中的前两行。

这些是我的代码。

    while (<PEPTIDELIST>) {
        next if $_ !=~ "##";
        chomp $_;
        @data = split /t/;
        chomp $_;
        next if /Sequence/;
        chomp $_;
    $npeptides++;
 #  print "debug: 0: $data[0]  1:  $data[1]  2:  $data[2] 3:   
 $data[3]     
 n" if ( $debug );
    my $pepseq = $data[1];
    #print $pepseq."n";
    foreach my $header (keys %sequence) {
    #print "looking for $pepseq in $header n";
    if ($sequence{$header} =~ /$pepseq/ ) {
       print "matched $pepseq in protein $header" if ( $debug );
        # my $in =<STDIN>;
        if ( $header =~ /(ENSGALPS+)s.+(ENSGALGS+)/  ) {
            print "debug: $1  $2 have the pep = $pepseq nn" if (  
 $debug);
            my $lprot = $1;
            my $lgene = $2;
             $gccount{$lgene}++;
             $pccount{$lprot}++;
          #  print "$1" if($debug);
          #  print "$2" if ($debug);
                print OUT "$pepseq,$1,$2n";
                }
            }
    }
    my $ngenes = keys %gccount;
    my $nprots = keys %pccount;

不知何故,肽不在输出列表中。 请帮我指出哪里出了问题?

谢谢

如果要

跳过包含##的行:

next if /##/;

如果您只想跳过以 ## 开头的行:

next if /^##/;

如果您总是想跳过前两行,无论内容如何:

next if $. < 3;

next if $_ !=~ "##";必须next if $_ =~ "##";

如果$_匹配##,请忽略这个谎言

最新更新