2 use lib
'/share/raid010/resequencing/soft/lib';
3 use lib
'E:/BGI/toGit/perlib/etc';
6 use Time
::HiRes qw
( gettimeofday tv_interval
);
11 our $opts='i:o:l:s:n:v:bd';
12 our($opt_i, $opt_o, $opt_v, $opt_b, $opt_d, $opt_l, $opt_s, $opt_n);
16 \t-i Genome FASTA file (./genome.fa)
17 \t-l Reads Length (76)
18 \t-n iNsert size (500)
19 \t-s Slip distance (8)
20 \t-o Output FQ prefix (./out)-N-RL-Sd_{1,2}.fa
21 \t-v Verbose level (undef=0)
22 \t-b No pause for batch runs
23 \t-d Debug Mode, for test only
28 $opt_i='./genome.fa' if ! $opt_i;
35 $opt_n=500 if ! $opt_n;
36 $opt_l=76 if ! $opt_l;
38 $opt_o='./out' if ! $opt_o;
39 my $outfile="${opt_o}-${opt_n}-${opt_l}-${opt_s}";
40 my $lenB=$opt_n-$opt_l;
41 my $dep=int(20*$opt_l/$opt_s)/10;
43 my $maxN=int(.3*$opt_l);
45 print STDERR
"From [$opt_i] to [${opt_o}]-${opt_n}-${opt_l}-${opt_s}_{1,2}.fa, [$opt_n][$opt_l][$opt_s]\nPE depth will be [$dep].\n";
46 print STDERR
"DEBUG Mode on !\n" if $opt_d;
47 print STDERR
"Verbose Mode [$opt_v] !\n" if $opt_v;
48 unless ($opt_b) {print STDERR
'press [Enter] to continue...'; <>;}
52 $str =~ tr/acgtrymkswhbvdnxACGTRYMKSWHBVDNX/tgcayrkmswdvbhnxTGCAYRKMSWDVBHNX/;
53 my $rev = reverse $str;
54 #$rev =~ tr/[](){}<>/][)(}{></;
57 my $start_time = [gettimeofday
];
59 open G
,'<',$opt_i or die "Error opening $opt_i: $!\n";
60 open OA
,'>',$outfile.'_1.fa' or die "Error opening ${outfile}_1.fa: $!\n";
61 open OB
,'>',$outfile.'_2.fa' or die "Error opening ${outfile}_2.fa: $!\n";
66 my $seqname = $1 if($title =~ /^(\S+)/);
67 print STDERR
"[!]Seq. >$seqname:\b";
75 print STDERR
"\t$Len .\b";
76 for (my $i=0;$i<$Len-$opt_n;$i+=$opt_s) {
77 $str=substr $seq,$i,$opt_n;
78 $a=substr $str,0,$opt_l;
86 print OA
">${seqname}_",$t,'/1 ',$i+1,"\n$a\n";
87 print OB
">${seqname}_",$t,'/2 ',$i+$lenB+1,"\n$b\n";
96 my $stop_time = [gettimeofday
];
98 print STDERR
"\nTime Elapsed:\t",tv_interval
( $start_time, $stop_time )," second(s).\n";