免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2204 | 回复: 2
打印 上一主题 下一主题

程序报错 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-07-12 14:14 |只看该作者 |倒序浏览
Bareword "USAGE" not allowed while "strict subs" in use at slaf.pl line 27.
运行下面的程序总是报错,哪位大神帮忙改改啊
#!/usr/bin/perl -w
use strict;
use Net::Config;
use warnings;
use Getopt::Long;
use Data:umper;
use FindBin qw($Bin $Script);
use File::Basename qw(basename dirname);
my $BEGIN_TIME=time();
my $Time_Start = &sub_format_datetime(localtime($BEGIN_TIME));
print "rogram Starts TimeTime_Start\n";
my $version="1.0.0";
#######################################################################################

# ------------------------------------------------------------------
# GetOptions
# ------------------------------------------------------------------
my ($fIn1,$fIn2,$fIn3,$fOut);
GetOptions(
                                "help|?" =>\&USAGE,
                                "o:s"=>\$fOut,
                                "i1:s"=>\$fIn1,
                                "i2:s"=>\$fIn2,
                                "r:s"=>\$fIn3,

                                ) or &USAGE;
USAGE unless ($fIn1 and $fIn2 and $fIn3 and $fOut);

open (fIN1,$fIn1)||die "$!";
open (fIN2,$fIn2)||die "$!";
open (OUT,">$fOut"||die "$!";
my %part;
$/="@";
my $len=$fIn3;
while(my $line1=<fIN1>,my $line2=<fIN2>{
        chomp($line1,$line2);
        next if($line1=~/^$/||$line2=~/^$/);
        my $initational=0;
        my ($nam1,$seq1,$qc1)=(split/\n/,$line1)[0,1,3];
        #print "$nam1";
        my ($nam2,$seq2,$qc2)=(split/\n/,$line2)[0,1,3];
        my ($ind1,$mN1)=split(/,/,$nam1);
        #print "$nam1\n";
        $seq1=substr($seq1,$initational,$len);
        $qc1=substr($qc1,$initational,$len);
        $seq2=substr($seq2,$initational,$len);
        $qc2=substr($qc2,$initational,$len);
        my ($ind2,$mN2)=split(/,/,$nam2);
        $seq2=~tr/ATGC/TACG/;
        my $str=reverse $seq2;
        my $str1=reverse $qc2;
        $part{$ind1}++;
        print OUT">$ind1\n";
        print OUT"$mN1\n";
        print OUT"$seq1","XXXXXXXXXX","$str\n";
        print OUT"$qc1","aaaaaaaaaa","$str1\n";
}
$/="\n";
foreach my $part (keys %part) {
        print OUT"$part\t$part{$part}\n";
}
close fIN1;
close fIN2;
#print OUT "";
close OUT;
#######################################################################################
my $Time_End   = sub_format_datetime(localtime(time()));
print STDOUT "rogram Ends TimeTime_End\nDone. Total elapsed time : ",time()-$BEGIN_TIME,"s\n";
#######################################################################################

# ------------------------------------------------------------------
# sub function
# ------------------------------------------------------------------
#######################################################################################

sub ABSOLUTE_DIR{ #$pavfile=&ABSOLUTE_DIR($pavfile);
        my $cur_dir=`pwd`;chomp($cur_dir);
        my ($in)=@_;
        my $return="";
        if(-f $in){
                my $dir=dirname($in);
                my $file=basename($in);
                chdir $dir;$dir=`pwd`;chomp $dir;
                $return="$dir/$file";
        }elsif(-d $in){
                chdir $in;$return=`pwd`;chomp $return;
        }else{
                warn "Warning just for file and dir\n";
                exit;
        }
        chdir $cur_dir;
        return $return;
}

#######################################################################################

sub max{#&max(lists or arry);
        #求列表中的最大值
        my $max=shift;
        my $temp;
        while (@_) {
                $temp=shift;
                $max=$max>$temp?$maxtemp;
        }
        return $max;
}

#######################################################################################

sub min{#&min(lists or arry);
        #求列表中的最小值
        my $min=shift;
        my $temp;
        while (@_) {
                $temp=shift;
                $min=$min<$temp?$mintemp;
        }
        return $min;
}

#######################################################################################

sub revcom(){#&revcom($ref_seq);
        #获取字符串序列的反向互补序列,以字符串形式返回。ATTCCC->GGGAAT
        my $seq=shift;
        $seq=~tr/ATCGatcg/TAGCtagc/;
        $seq=reverse $seq;
        return uc $seq;                          
}

#######################################################################################

sub GetTime {
        my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst)=localtime(time());
        return sprintf("%4d-%02d-%02d %02d:%02d:%02d", $year+1900, $mon+1, $day, $hour, $min, $sec);
}

#######################################################################################

sub sub_format_datetime {#Time calculation subroutine
        my($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = @_;
        $wday = $yday = $isdst = 0;
        sprintf("%4d-%02d-%02d %02d:%02d:%02d", $year+1900, $mon+1, $day, $hour, $min, $sec);
}

sub USAGE {#
        my $usage=<<"USAGE";
ProgramName:
Version:        $version
Contact:        Program Date:   2010.6.9
Modify:          2010-7-27  ##move adapter recongnize programs to my bin dir
Description:        this program is used to ......
Usage:
  Options:
  -i1 <file>  input file,fasta format,fq,forced
   -i2 <file>  input file,fasta format,fq,forced
  -o <file>  output file,forced  
  -r <variable> input variable,int,forced
  -h         Help

USAGE
        print $usage;
        exit;
}

论坛徽章:
2
CU大牛徽章
日期:2013-04-17 11:46:28CU大牛徽章
日期:2013-04-17 11:46:39
2 [报告]
发表于 2012-07-12 14:23 |只看该作者
本帖最后由 cdtits 于 2012-07-12 14:23 编辑

貌似这个:
  1. &USAGE unless ($fIn1 and $fIn2 and $fIn3 and $fOut);
复制代码

论坛徽章:
0
3 [报告]
发表于 2012-07-12 14:26 |只看该作者
谢谢 写得时候把&给删了回复 2# cdtits


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP