运行perl脚本并得到“Error in option spec:“

c2e8gylq  于 2023-03-23  发布在  Perl
关注(0)|答案(1)|浏览(311)

我是一个运行Perl脚本的新手,我遇到了一些问题,我怀疑这些问题是由于变量的赋值造成的。
以下是原始脚本的开头:

#!/usr/bin/perl -w

#####################################
# gbstrim.pl 
# John Garbe
# June 2016
# 
#
#####################################

=head1 NAME

gbstrim.pl - 
 - Trim padding and/or cut site residue from beginning of reads
 - Trim sequencing adapter from ends of reads
 - Trim all reads to length

NOTE: this doesn't handle paired-end data

=head1 SYNOPSIS

gbstrim.pl --enzyme1 bamhi --enzyme2 psti --read R1 [--threads 1] [--minlength 20] --fastqfile file.fastq --outputfile out.fastq 

=head1 DESCRIPTION

Options:
    --fastqfile sample.fastq : fastq file of reads to process, can be gz compressed
    --outputfile sample.gbstrim.fastq : fastq file of processed reads
    --enzyme1 bamhi : First restriciton enzyme used in library creation
    --enzyme2 psti : Second restriciton enzyme used in library creation
    --read R1 : Specify if the provided fastq file is the R1 or R2 read
    --minlength 20 : discard reads shorter than minlength (default: 20)
    --maxlength 95 : trim all reads longer than maxlength to maxlength (default: readlength - length of longest padding sequence)
    --croplength 95 : trim down longer reads and discard shorter reads
    --removecutsite : trim off cut sites as well
    --threads 1 : Number of cpu cores cutadapt should use (default: 1)
    --verbose : Print additional details while running
    --help : Display usage information

Advanced options:
    --r1padding C,TG,AAG,GCTC : comma-separated list of 5' padding sequences. To include a pad of zero start with a comma: ,C,TG,AAG,GCTC
    --r2padding C,TG,AAG,GCTC : comma-separated list of 3' padding sequences. To include a pad of zero start with a comma: ,C,TG,AAG,GCTC
    --r1overhang AGCT : Overhang sequence left by first restriction enzyme
    --r2overhang AGCT : Overhang sequence left by second restriction enzyme
    --adapter CTGTCTCTTATACACATCTCCGAG : sequencing primer adapter to trim from 3' end of reads
    --debug : Print output useful for debugging
=cut

##################### Initialize ###############################

use Getopt::Long;
use Pod::Usage;
use FindBin;
use lib "$FindBin::RealBin";

# set defaults
$r1adapter = "CTGTCTCTTATACACATCTCCGAG";
$r2adapter = "CTGTCTCTTATACACATCTGACGC";
$minlength = 20;
GetOptions("help" => \$help,
       "verbose" => \$verbose,
       "threads=i" => \$threads,
       "fastqfile=s" => \$fastqfile,
       "outputfile=s" => \$outputfile,
       "enzyme1=s" => \$r1enzyme,
       "enzyme2=s" => \$r2enzyme,
       "read=s" => \$read,
       "croplength=i" => \$croplength,
       "removecutsite" => \$removecutsite,

       # advanced options
       "r1overhang=s" => \$r1overhang,
       "r2overhang=s" => \$r2overhang,
       "r1padding=s" => \$r1padding,
       "r2padding=s" => \$r2padding,
       "debug" => \$debug,
       "minlength=i" => \$minlength,
       "maxlength=i" => \$maxlength,
       "r1adapter=s" => \$r1adapter,
       "r2adapter=s" => \$r2adapter,
    ) or pod2usage;
pod2usage(q(-verbose) => 3) if ($help);
if ($#ARGV >= 0) {
    print "Unknown commandline parameters: @ARGV\n";
    pod2usage;
}
if (! ($fastqfile and $outputfile and $read and $r1enzyme)) {
    print "--fastqfile, --outputfile, --read, --enzyme1 and enzyme2 are required\n";
    pod2usage;
}
die "Cannot find fastq file $fastqfile\n" if (! -e $fastqfile);

这是我在编辑和指定输入文件和酶后试图运行的脚本。

#!/usr/bin/perl -w

#####################################
# gbstrim.pl 
# John Garbe
# June 2016
# 
#
#####################################

=head1 NAME

gbstrim.pl - 
 - Trim padding and/or cut site residue from beginning of reads
 - Trim sequencing adapter from ends of reads
 - Trim all reads to length

NOTE: this doesn't handle paired-end data

=head1 SYNOPSIS

gbstrim.pl --enzyme1 bamhi --enzyme2 nsii --read R1 [--threads 1] [--minlength 20] --fastqfile test.fastq.gz --outputfile trim_test.fastq.gz

=head1 DESCRIPTION

Options:
    --fastqfile test.fastq.gz : fastq file of reads to process, can be gz compressed
    --outputfile outputfile trim_test.fastq.gz : fastq file of processed reads
    --enzyme1 bamhi : First restriciton enzyme used in library creation
    --enzyme2 nsii : Second restriciton enzyme used in library creation
    --read R1 : Specify if the provided fastq file is the R1 or R2 read
    --minlength 20 : discard reads shorter than minlength (default: 20)
    --maxlength 95 : trim all reads longer than maxlength to maxlength (default: readlength - length of longest padding sequence)
    --croplength 95 : trim down longer reads and discard shorter reads
    --removecutsite : trim off cut sites as well
    --threads 1 : Number of cpu cores cutadapt should use (default: 1)
    --verbose : Print additional details while running
    --help : Display usage information

Advanced options:
    --r1padding C,TG,AAG,GCTC : comma-separated list of 5' padding sequences. To include a pad of zero start with a comma: ,C,TG,AAG,GCTC
    --r2padding C,TG,AAG,GCTC : comma-separated list of 3' padding sequences. To include a pad of zero start with a comma: ,C,TG,AAG,GCTC
    --r1overhang AGCT : Overhang sequence left by first restriction enzyme
    --r2overhang AGCT : Overhang sequence left by second restriction enzyme
    --adapter CTGTCTCTTATACACATCTCCGAG : sequencing primer adapter to trim from 3' end of reads
    --debug : Print output useful for debugging
=cut

##################### Initialize ###############################

use Getopt::Long;
use Pod::Usage;
use FindBin;
use lib "$FindBin::RealBin";

# set defaults
$r1adapter = "CTGTCTCTTATACACATCTCCGAG";
$r2adapter = "CTGTCTCTTATACACATCTGACGC";
$minlength = 20;
GetOptions("help" => \$help,
       "verbose" => \$verbose,
       "threads=i" => \$threads,
       "test.fastq.gz=s" => \$fastqfile,
       "trim_test.fastq.gz=s" => \$outputfile,
       "bamhi=s" => \$r1enzyme,
       "nsii=s" => \$r2enzyme,
       "R1" => \$read,
       "croplength=i" => \$croplength,
       "removecutsite" => \$removecutsite,

       # advanced options
       "r1overhang=s" => \$r1overhang,
       "r2overhang=s" => \$r2overhang,
       "r1padding=s" => \$r1padding,
       "r2padding=s" => \$r2padding,
       "debug" => \$debug,
       "minlength=i" => \$minlength,
       "maxlength=i" => \$maxlength,
       "r1adapter=s" => \$r1adapter,
       "r2adapter=s" => \$r2adapter,
    ) or pod2usage;
pod2usage(q(-verbose) => 3) if ($help);
if ($#ARGV >= 0) {
    print "Unknown commandline parameters: @ARGV\n";
    pod2usage;
}
if (! ($fastqfile and $outputfile and $read and $r1enzyme)) {
    print "--fastqfile, --outputfile, --read, --enzyme1 and enzyme2 are required\n";
    pod2usage;
}
die "Cannot find fastq file $fastqfile\n" if (! -e $fastqfile);

这是我收到的错误消息:
Error in option spec: "test.fastq.gz=s"
Error in option spec: "trim_test.fastq.gz=s"

uurity8g

uurity8g1#

您必须运行原始文件,而不进行更改。从命令行运行时,请指定选项的值,就像使用任何UNIX命令一样,例如:

gbstrim.pl --enzyme1 bamhi --enzyme2 nsii --read R1 --fastqfile test.fastq.gz --outputfile trim_test.fastq.gz

不要修改脚本内的**选项。

相关问题