annotate siRNA.pl @ 1:49ce0a59cbe1 draft

Uploaded
author big-tiandm
date Thu, 18 Sep 2014 21:43:28 -0400
parents 07745c0958dd
children f466394ee1fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
1 #!/usr/bin/perl -w
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
2 my $version=1.00;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
3 use strict;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
4 use warnings;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
5 use Getopt::Long;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
6 use Getopt::Std;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
7 use threads;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
8 use threads::shared;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
9 use Parallel::ForkManager;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
10 use lib '/leofs/biotrans/chentt/perl_module/';
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
11 #perl ../siRNA.pl -i config -g /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/test/ref/genome.fa -f /share_bio/hs4/disk3-4/Reference/Plants/Rice_TIGR/Reference/TIGR/version_6.1/all.dir/all.gff3 -path /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/ -o /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/test -t 3 -rfam /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/test/ref/Rfam.fasta -idx /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/test/ref/genome -idx2 /leofs/biotrans/projects/rice/smallRNA/sRNA_package/bin/test/ref/rfam -deg deg -n 25 -nat class/nat_1 -repeat class/repeat_1 -cen centromere_TIGR.txt -format fastq
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
12 print "
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
13 #####################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
14 # #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
15 # sRNA cluster #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
16 # #
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
17 #####################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
18 ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
19 ###########################################################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
20 my $usage="$0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
21 Options:
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
22 -i input file# raw data file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
23 -tag string #raw data sample name
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
24 -g genome file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
25 -f gff file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
26
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
27 -o workdir file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
28 -path script path
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
29 -t int, number of threads [1]
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
30 -format fastq, fq, fasta or fa
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
31 -idx string, genome file index, file-prefix #(must be indexed by bowtie-build) The parameter
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
32 string must be the prefix of the bowtie index. For instance, if
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
33 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
34 the prefix is 'h_sapiens_37_asm'.##can be null
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
35 -mis int number of allowed mismatches when mapping reads to genome, default 0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
36 -rfam string, input file# rfam database file.
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
37 -idx2 string, rfam file index, file-prefix #(must be indexed by bowtie-build) The parameter
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
38 string must be the prefix of the bowtie index. For instance, if
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
39 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
40 the prefix is 'h_sapiens_37_asm'.##can be null
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
41
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
42 -v int report end-to-end hits w/ <=v mismatches; ignore qualities,default 0; used in rfam alignment
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
43
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
44 -a string, ADAPTER string. default is ATCTCGTATG.
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
45 -n int max hits number,default 25; used in genome alignment
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
46 -d int distance of tag to merged a cluster; default 100
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
47 -p cluster method F :conventional default is F
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
48 T :NIBLES
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
49 -l int the length of the upstream and downstream,default 1000;used in position annotate
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
50
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
51 -nat natural antisense transcripts file
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
52 -repeat repeat information file out of Repeatmasker
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
53 -deg file config of de sample
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
54 -cen centromere file input
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
55 -span plot span, default 50000
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
56 ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
57
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
58 my %options;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
59 GetOptions(\%options,"i:s@","tag:s@","g=s","f=s","o=s","a:s","path:s","p=s","format=s","nat:s","repeat:s","deg:s","n:i","mis:i","rfam:s","t:i","v:i","d:i","l:i","idx:s","idx2:s","cen:s","span:s","h");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
60
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
61 my @inputfiles=@{$opts{'i'}};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62 my @inputtags=@{$opts{'tag'}};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
63
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
64 #my $config=$options{'i'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
65 my $genome_fa=$options{'g'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
66 my $gff=$options{'f'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
67 ##########################################################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
68 my $predir=`pwd`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
69 chomp $predir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
70 my $workdir=defined($options{'o'}) ? $options{'o'}:$predir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
71
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
72 my $path=$options{'path'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
73
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
74 my $t=defined($options{'t'})? $options{'t'}:1; #threads number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
75
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
76 my $mis=defined $options{'mis'} ? $options{'mis'}:0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
77
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
78 my $mis_rfam=defined $options{'v'} ? $options{'v'}:0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
79
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
80 my $hit=defined $options{'n'}?$options{'n'}:25;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
81
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
82 my $distance_of_merged_tag=defined $options{'d'} ? $options{'d'}:100;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
83
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
84 my $up_down_dis=defined $options{'l'} ?$options{'l'}:1000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
85
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
86 my $cluster_mothod=defined $options{'p'}?$options{'p'}:"F";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
87
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
88 my $format=$options{'format'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
89 #if ($format ne "fastq" && $format ne "fq" && $format ne "fasta" && $format ne "fa") {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
90 # die "Parameter \"-format\" is error! Parameter is fastq, fq, fasta or fa\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
91 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
92
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
93 my $adpter="ATCTCGTATG"; #adapter
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
94 if (defined $opts{'a'}) {$a=$opts{'a'};}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
95
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
96 #print help if that option is used
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
97 if($options{h}){die $usage;}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
98
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
99 my $phred_qv=64;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
100 my $sample_number;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
101 my ($dir,$dir_tmp);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
102 ################################ MAIN ##################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
103 print "\ncluster program start:";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
104 my $time=Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
105 make_dir_tmp();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
106
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
107 my (@filein,@mark,@clip);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
108 my $mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
109 my $sample_mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
110
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
111 my $config=$workdir."/input_config";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
112 open CONFIG,">$config";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
113 for (my $i=0;$i<@inputfiles;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
114 print CONFIG $inputfiles[$i],"\t",$inputtags[$i],"\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
115 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
116 close CONFIG;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
117
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
118 read_config();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
119
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
120 trim_adapter_and_filter();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
121
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
122 my $filter_out=$dir."preProcess\/"."collapse_reads_out.fa";## raw clean data
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
123 my $data2=$filter_out; ### mirbase not mapped reads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
124 my $data3=$dir."\/rfam_match\/rfam_not_mapped\.fa"; ### rfam not mapped reads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
125 my $bed=$dir."cluster\/"."sample\.bed";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
126 my $read=$dir."cluster\/"."sample_reads\.cluster";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
127 my $read_txt=$dir."cluster\/"."cluster\.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
128 my $rpkm=$dir."cluster\/"."sample_rpkm\.cluster";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
129 my $preprocess;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
130 my $cluster_file;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
131 my $annotate_dir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
132 my $deg_dir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
133 my %id;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
134 for (my $i=0;$i<@mark ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
135 $id{$mark[$i]}=$i+4;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
136 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
137 group_and_filter(); #collapse reads to tags
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
138
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
139 rfam();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
140
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
141 my @map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
142 my $map_tag=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
143 genome();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
144
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
145 bwt2bed();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
146
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
147 cluster();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
148
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
149 quantify();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
150
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
151 phase();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
152
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
153 class();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
154
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
155 annotate();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
156
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
157 genome_length();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
158
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
159 plot();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
160
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
161 my @pairdir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
162 if (defined($options{'deg'})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
163 dec();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
164 infor_merge();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
165 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
166 html();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
167 print "\ncluster program end:";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
168 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
169 ############################sub program###################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
170 sub make_dir_tmp{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
171
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
172 #make temporary directory
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
173 if(not -d "$workdir\/cluster_runs_$time"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
174 mkdir("$workdir\/cluster_runs_$time");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
175 mkdir("$workdir\/cluster_runs_$time\/ref\/");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
176 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
177
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
178 $dir="$workdir\/cluster_runs_$time\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
179 print STDERR "mkdir $dir\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
180 return;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
181 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
182
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
183 sub read_config{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
184 open IN,"<$config";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
185 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
186 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
187 my @tmp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
188 push @filein,$tmp[0];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
189 push @mark,$tmp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
190 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
191 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
192 if (@filein != @mark) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
193 die "Maybe config file have some wrong!!!\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
194 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
195 $sample_number=@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
196 $mark=join "\t",@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
197 $sample_mark=join "\#",@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
198 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
199
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
200
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
201 sub trim_adapter_and_filter{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
202 my $time=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
203 $preprocess=$dir."preProcess/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
204 mkdir $preprocess;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
205 my $can_use_threads = eval 'use threads; 1';
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
206 if ($can_use_threads) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
207 # Do processing using threads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
208 my @filein1=@filein; my @mark1=@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
209 while (@filein1>0) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
210 my @thrs; my @res;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
211 for (my $i=0;$i<$t ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
212 last if(@filein1==0);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
213 my $in=shift @filein1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
214 my $out=shift @mark1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
215 push @clip,$dir."preProcess\/$out\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
216 $thrs[$i]=threads->create(\&clips,$in,$out);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
217 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
218 for (my $i=0;$i<@thrs;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
219 $res[$i]=$thrs[$i]->join();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
220 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
221 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
222 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
223 else {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
224 # Do not processing using threads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
225 for (my $i=0;$i<@filein ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
226 my $in=$filein[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
227 my $out=$mark[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
228 push @clip,$dir."preProcess\/$out\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
229 &clips($in,$out);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
230 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
231 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
232 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
233
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
234 sub clips{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
235 my ($filein,$fileout)=@_;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
236 my $adapter=$dir."preProcess\/$fileout\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
237 if($format eq "fq" || $format eq "fastq"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
238 my $clip=`$path\/fastx_clipper -a $adpter -M 6 -Q $phred_qv -i $filein -o $adapter`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
239 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
240 if($format eq "fa" || $format eq "fasta"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
241 my $clip=`$path\/fastx_clipper -a $adpter -M 6 -i $filein -o $adapter`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
242 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
243 #my $clean=$dir."preProcess\/$fileout\_clean.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
244 #my $filter=`filterReadsByLength.pl -i $adapter -o $clean -min 18 -max 40 `;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
245 return $fileout;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
246 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
247
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
248 sub group_and_filter{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
249 #my ($ins,$data)=@_;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
250 my @ins=@clip;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
251 my $str="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
252 my $group_out_file=$dir."preProcess\/"."collapse_reads.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
253 #print "$$ins[0]\t$$ins[0]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
254 for (my $i=0;$i<@clip;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
255 $str .="-i $clip[$i] ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
256 #print "$$ins[$i]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
257 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
258 my $group=`perl $path\/collapseReads2Tags.pl $str -mark seq -o $group_out_file -format $format`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
259 print "perl $path\/collapseReads2Tags.pl $str -mark seq -o $group_out_file -format $format\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
260
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
261 my $l_out=$dir."preProcess\/"."collapse_reads_18-40.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
262 my $length_f=`perl $path\/filterReadsByLength_1.pl -i $group_out_file -o $l_out -min 18 -max 40 -mark $sample_mark`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
263 print "perl $path\/filterReadsByLength_1.pl -i $group_out_file -o $l_out -min 18 -max 40 -mark $sample_mark\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
264 my $cout_f=`perl $path\/filterReadsByCount.pl -i $l_out -o $filter_out -mark $sample_mark`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
265 print "perl $path\/filterReadsByCount.pl -i $l_out -o $filter_out -mark $sample_mark\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
266 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
267 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
268
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
269 sub rfam{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
270 if (defined $options{'idx2'}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
271 system("perl $path\/rfam.pl -i $data2 -ref $options{rfam} -v $mis_rfam -p $t -o $dir -index $options{idx2}");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
272 }else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
273 system("perl $path\/rfam.pl -i $data2 -ref $options{rfam} -v $mis_rfam -p $t -o $dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
274 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
275 my $tag=join "\\;" ,@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
276 my $rfam_count=`perl $path\/count_rfam_express.pl -i $dir\/rfam_match\/rfam_mapped.bwt -tag $tag -o $dir\/rfam_match\/rfam_non-miRNA_annotation.txt`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
277 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
278 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
279 sub genome{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
280 if(defined $options{'idx'}){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
281 system("perl $path\/matching.pl -i $data3 -g $genome_fa -v $mis -p $t -r $hit -o $dir -index $options{idx}") ;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
282 }else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
283 system("perl $path\/matching.pl -i $data3 -g $genome_fa -v $mis -p $t -r $hit -o $dir ") ;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
284 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
285 #=================== mapping sta ===================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
286 my $map_file=$dir."genome_match\/genome_mapped\.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
287 open (MAP,"<$map_file")||die"$!";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
288 print "\n#each sample mapping reads sta:\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
289 print "#$mark\ttotal\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
290 while (my $ID=<MAP>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
291 chomp $ID;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
292 my @tmp=split/\:/,$ID;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
293 my @exp=split/\_/,$tmp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
294 $exp[-1] =~ s/^x//;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
295 for (my $i=0;$i<@exp ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
296 $map_read[$i]+=$exp[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
297 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
298 $map_tag++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
299 my $seq=<MAP>;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
300 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
301 my $map_read=join"\t",@map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
302 print "$map_read\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
303 print "#total mapped tags:$map_read\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
304 close MAP;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
305 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
306 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
307
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
308 sub bwt2bed{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
309 $cluster_file=$dir."cluster\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
310 mkdir ("$cluster_file");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
311 print "sam file changed to bed file\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
312 my ($file) = $dir."genome_match\/genome_mapped\.bwt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
313
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
314 my $sam2bed=`perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed `;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
315 print "perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
316 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
317 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
318
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
319 sub cluster{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
320 print "tags is ready to merged clusters\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
321 my ($file) =$bed;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
322 if ($cluster_mothod eq "F") {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
323 my $cluster=`perl $path\/conventional.pl -i $file -d $distance_of_merged_tag -n $sample_number -mark $sample_mark -o $read -t $read_txt`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
324 print "Using converntional method\n perl $path\/conventional.pl -i $file -d $distance_of_merged_tag -n $sample_number -mark $sample_mark -o $read -t $read_txt\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
325 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
326 elsif($cluster_mothod eq "T"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
327 my $cluster=`perl $path\/nibls.pl -f $file -m $distance_of_merged_tag -o $read -t $read_txt -mark $sample_mark`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
328 print "Using nibls method\n perl $path\/nibls.pl -f $file -m $distance_of_merged_tag -o $read -t $dir\/cluster.txt -mark $sample_mark\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
329 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
330 else{print "\-p is wrong!\n\n";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
331 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
332 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
333
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
334
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
335 sub quantify{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
336 print "clusters is ready to quantified\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
337 my @depth=@map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
338 pop @depth;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
339 my $depth=join ",",@depth;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
340 my $quantify=`perl $path\/quantify.pl -i $read -d $depth -o $rpkm`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
341 print "perl $path\/quantify.pl -i $read -d $depth -o $rpkm\n\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
342 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
343 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
344
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
345 sub phase{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
346 $annotate_dir=$dir."annotate\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
347 mkdir ("$annotate_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
348 print "clusters is to predict phase siRNA\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
349 my $phase=`perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
350 print "perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out\n\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
351 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
352 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
353
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
354 sub class{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
355 print "clusters is ready to annotate by source\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
356 my $nat=$options{'nat'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
357 my $repeat=$options{'repeat'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
358 my $class=`perl $path\/ClassAnnotate.pl -i $rpkm -g $gff -n $nat -r $repeat -p $annotate_dir\/phase.out -o $annotate_dir\/sample_class.anno -t $annotate_dir\/nat.out -l $dir\/ref\/genelist.txt`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
359 print "perl $path\/ClassAnnotate.pl -i $rpkm -g $gff -n $nat -r $repeat -p $annotate_dir\/phase.out -o $annotate_dir\/sample_class.anno -t $annotate_dir\/nat.out -l $dir\/ref\/genelist.txt\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
360 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
361
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
362 sub annotate{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
363 print "clusters is ready to annotate by gff file\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
364 my $file="$annotate_dir\/sample_class.anno";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
365 my $annotate=`perl $path\/Annotate.pl -i $file -g $dir\/ref\/genelist.txt -d $up_down_dis -o $annotate_dir\/sample_c_p.anno`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
366 print "perl $path\/Annotate.pl -i $file -g $dir\/ref\/genelist.txt -d $up_down_dis -o $annotate_dir\/sample_c_p.anno\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
367 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
368 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
369
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
370 sub dec{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
371 print "deg reading\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
372 my $deg_file=$options{'deg'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
373 open IN,"<$deg_file";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
374 my @deg;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
375 my $s=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
376 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
377 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
378 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
379 $deg[$s]=$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
380 my @ea=split/\s+/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
381 push @pairdir,"$ea[0]_VS_$ea[1]\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
382 #print "$deg[$s]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
383 $s++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
384 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
385 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
386 $deg_dir=$dir."deg\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
387 mkdir ("$deg_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
388 my $max_process = 10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
389 my $pm = new Parallel::ForkManager( $max_process );
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
390 my $number=@deg-1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
391 foreach(0..$number){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
392 $pm->start and next;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
393 &dec_pel($deg[$_]);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
394 $pm->finish;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
395 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
396 $pm->wait_all_children;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
397 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
398
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
399 sub dec_pel{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
400 print "start:\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
401 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
402 my $sample=shift(@_);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
403 my @each=split/\s+/,$sample;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
404 print "$each[0]\t$each[1]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
405 my $deg_sample_dir=$deg_dir."$each[0]_VS_$each[1]\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
406 mkdir ("$deg_sample_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
407 my $deg=`perl $path\/DEGseq_2.pl -i $read -outdir $deg_sample_dir -column1 $id{$each[0]} -mark1 $each[0] -column2 $id{$each[1]} -mark2 $each[1]`; #-depth1 -depth2
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
408 my $time2=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
409 print "end:\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
410 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
411 sleep 1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
412 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
413
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
414 sub infor_merge{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
415 my ($input,$mark);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
416 foreach (@pairdir) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
417 print "@pairdir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
418 $mark.=" -mark $_ ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
419 $input.=" -i $dir/deg\/$_\/output_score\.txt ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
420 print "$input\n$mark\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
421 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
422 my $infor_merge=`perl $path\/SampleDEGseqMerge.pl $input $mark -f $annotate_dir\/sample_c_p.anno -n $sample_number -o $dir\/total.result `;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
423 print "perl $path\/SampleDEGseqMerge.pl $input $mark -f $annotate_dir\/sample_c_p.anno -n $sample_number -o $dir\/total.result\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
424 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
425
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
426 sub genome_length{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
427 my $length=`perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
428 print "perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length\n\n"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
429
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
430 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
431
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
432 sub plot{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
433 my $plot_file="$dir\/plot\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
434 mkdir ("$plot_file");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
435 my $genome_plot="$dir\/plot\/genome\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
436 mkdir ("$genome_plot");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
437 #genome cluster
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
438 my $span=defined($options{span})?$options{span}:50000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
439 foreach (1..$sample_number) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
440 my $mark=$mark[$_-1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
441 my $cen="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
442 if (defined $options{cen}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
443 $cen="-cen $options{cen}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
444 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
445 my $plot=`perl $path\/sRNA_rpkm_distribution_along_genome.pl -c $rpkm -n $_ -mark $mark -span $span -l $dir\/ref\/genome\.length $cen -o $genome_plot\/$mark\.html -out $genome_plot\/$mark\.txt`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
446 print "perl $path\/sRNA_rpkm_distribution_along_genome.pl -c $rpkm -n $_ -mark $mark -span $span -l $dir\/ref\/genome\.length $cen -o $genome_plot\/$mark\.html -out $genome_plot\/$mark\.txt\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
447 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
448
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
449 my $chr_plot_dir="$dir\/plot\/chr\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
450 mkdir("$chr_plot_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
451 my %chr;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
452 open LEN,"<$dir\/ref\/genome\.length";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
453 while (my $aline=<LEN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
454 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
455 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
456 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
457 $chr{$temp[0]}=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
458 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
459 close LEN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
460 foreach my $chr (sort keys %chr) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
461 my $cen="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
462 if (defined $options{cen}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
463 $cen="-cen $options{cen}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
464 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
465 my $chr_plot=`perl $path\/chr_plot.pl -l $chr{$chr} -chro $chr -g $dir\/ref\/genelist.txt -span $span -c $rpkm -mark $sample_mark -o $chr_plot_dir\/$chr\.html`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
466 print "perl $path\/chr_plot.pl -l $chr{$chr} -chro $chr -g $dir\/ref\/genelist.txt -span $span -c $rpkm -mark $sample_mark -o $chr_plot_dir\/$chr\.html\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
467 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
468 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
469
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
470 sub html{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
471 my $pathfile="$dir/path.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
472 open PA,">$pathfile";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
473 print PA "$config\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
474 print PA "$preprocess\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
475 print PA "$dir"."rfam_match\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
476 print PA "$dir"."genome_match\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
477 print PA "$cluster_file\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
478 print PA "$annotate_dir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
479 print PA "$deg_dir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
480 close PA;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
481 my $html=`perl $path\/html.pl -i $pathfile -format $format -o $dir/result.html`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
482 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
483
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
484 sub Time{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
485 my $time=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
486 my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
487 $month++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
488 $year+=1900;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
489 if (length($sec) == 1) {$sec = "0"."$sec";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
490 if (length($min) == 1) {$min = "0"."$min";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
491 if (length($hour) == 1) {$hour = "0"."$hour";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
492 if (length($day) == 1) {$day = "0"."$day";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
493 if (length($month) == 1) {$month = "0"."$month";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
494 print "$year-$month-$day $hour:$min:$sec\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
495 return("$year-$month-$day-$hour-$min-$sec");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
496 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
497 #################################################################################