experchange > perl

(10-30-19, 04:48 AM)
Dear every one:
I try to write a perl script to delet the content of file carp01_1_both.txt as same as from another file carp-carp01_TKD181002053-1_1_sg.txt, so to get a new file from file carp-carp01_TKD181002053-1_1_sg.txt but excluding file carp01_1_both.txt. However, when I run this scrip, it does not work, and display the information as follows:
...

Semicolon seems to be missing at carp01_1_both.txt line 44993.
Number found where operator expected at carp01_1_both.txt line 44994, near "55659 1"
(Missing operator before 1?)
Number found where operator expected at carp01_1_both.txt line 44994, near "ATCACG 55"
(Do you need to predeclare ATCACG?)
Number found where operator expected at carp01_1_both.txt line 44994, near "55 116"
(Missing operator before 116?)

syntax error at carp01_1_both.txt line 1, near "979:"

carp01_1_both.txt:
HISEQ:979:HM2HCBCX2:1:1110:15064:80819 1:N:0:ATCACG 62 123 250 62 + SINE3-1 45 106 590
HISEQ:979:HM2HCBCX2:1:2104:4144:84852 1:N:0:ATCACG 100 161 250 62 - SINE3-1 45 106 590
HISEQ:979:HM2HCBCX2:1:1102:2661:55870 1:N:0:ATCACG 141 202 250 62 + SINE3-1 45 106 590
HISEQ:979:HM2HCBCX2:1:1110:21298:76907 1:N:0:ATCACG 29 221 250 193 + SINE3-1 3 197 590
HISEQ:979:HM2HCBCX2:1:2116:10990:92099 1:N:0:ATCACG 95 151 250 57 + SINE3-1 45 101 590
...

carp-carp01_TKD181002053-1_1_sg.txt:
HISEQ:979:HM2HCBCX2:1:1115:9907:8048 1:N:0:ATCACG 117 243 250 127 + SINE3-1a 210 335 570
HISEQ:979:HM2HCBCX2:1:2208:4628:64650 1:N:0:ATCACG 5 49 250 45 - SINE3-1 45 89 590
HISEQ:979:HM2HCBCX2:1:1212:6335:22852 1:N:0:ATCACG 2 250 250 249 + SINE3-1 234 486 590
HISEQ:979:HM2HCBCX2:1:1103:16183:52106 1:N:0:ATCACG 1 250 250 250 - SINE3-1a 229 474 570
HISEQ:979:HM2HCBCX2:1:2211:8958:6423 1:N:0:ATCACG 1 250 250 250 - SINE3-1a 117 367 570
HISEQ:979:HM2HCBCX2:1:1113:7857:35762 1:N:0:ATCACG 1 152 250 152 - SINE3-1 291 445 590
HISEQ:979:HM2HCBCX2:1:1206:12438:18002 1:N:0:ATCACG 1 249 250 249 - SINE3-1a 283 519 570
...

perl script:
#!/usr/bin/perl -w
open(NAME,"<$ARGV[0]")|| die;
open(SECON,"<$ARGV[1]")|| die;
open(SELEC,">$ARGV[2]")|| die;
$name = "";
%pair = ();

while(<NAME>){
chomp;
my @line = split("\t",$_);
$name = $line[0];
$pair{$name} = 1;
}

while(my $li = <SECON>){
chomp($li);
my @line = split("\t",$li);
$name = $line[0];
my $cont = $li;
if (exists $hash{$name}) { # if current read appeared before
next;
} else { # if it haven't been read before
print SELEC "$cont\n";
}
}

close NAME;
close SECON;
close SELEC;

Sincerely

Dong Liu
Uri Guttman (10-30-19, 08:01 AM)
On 10/29/19 10:48 PM, 刘东 wrote:
[..]
> near "55    116"
>     (Missing operator before     116?)
> syntax error at carp01_1_both.txt line 1, near "979:"


it appears that perl is trying to compile one of your data files. show
the command line where you run your script

> perl script:
> #!/usr/bin/perl -w better to use warnings than -w. also use strict is important
> open(NAME,"<$ARGV[0]")|| die;
> open(SECON,"<$ARGV[1]")|| die;
> open(SELEC,">$ARGV[2]")|| die; your die lines should say which file failed to open


uri
Similar Threads