annotate siRNA.pl @ 7:6aa0e8d63b17 draft

Deleted selected files
author big-tiandm
date Thu, 23 Oct 2014 22:46:32 -0400
parents f466394ee1fd
children
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 # #
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
15 # sRNA cluster #
0
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");
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
60 #print help if that option is used
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
61 if($options{h}){die $usage;}
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
62
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
63 my @filein=@{$options{'i'}};
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
64 my @mark=@{$options{'tag'}};
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
65
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
66 #my $config=$options{'i'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
67 my $genome_fa=$options{'g'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
68 my $gff=$options{'f'};
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
69
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
70
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
71 ##########################################################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
72 my $predir=`pwd`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
73 chomp $predir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
74 my $workdir=defined($options{'o'}) ? $options{'o'}:$predir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
75
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
76 my $path=$options{'path'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
77
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
78 my $t=defined($options{'t'})? $options{'t'}:1; #threads number
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
79
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
80 my $mis=defined $options{'mis'} ? $options{'mis'}:0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
81
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
82 my $mis_rfam=defined $options{'v'} ? $options{'v'}:0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
83
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
84 my $hit=defined $options{'n'}?$options{'n'}:25;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
85
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
86 my $distance_of_merged_tag=defined $options{'d'} ? $options{'d'}:100;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
87
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
88 my $up_down_dis=defined $options{'l'} ?$options{'l'}:1000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
89
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
90 my $cluster_mothod=defined $options{'p'}?$options{'p'}:"F";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
91
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
92 my $format=$options{'format'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
93 #if ($format ne "fastq" && $format ne "fq" && $format ne "fasta" && $format ne "fa") {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
94 # die "Parameter \"-format\" is error! Parameter is fastq, fq, fasta or fa\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
95 #}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
96
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
97 my $adpter="ATCTCGTATG"; #adapter
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
98 if (defined $options{'a'}) {$adpter=$options{'a'};}
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
99
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
100
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
101 my $phred_qv=64;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
102 my $sample_number;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
103 my ($dir,$dir_tmp);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
104 ################################ MAIN ##################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
105 print "\ncluster program start:";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
106 my $time=Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
107 make_dir_tmp();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
108
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
109 my @clip;
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
110 my $mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
111 my $sample_mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
112
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
113 my $config=$dir."/input_config";
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
114 open CONFIG,">$config";
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
115 for (my $i=0;$i<@filein;$i++) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
116 print CONFIG $filein[$i],"\t",$mark[$i],"\n";
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
117 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
118 close CONFIG;
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
119 if (@filein != @mark) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
120 die "Maybe config file have some wrong!!!\n";
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
121 }
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
122 $sample_number=@mark;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
123 $mark=join "\t",@mark;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
124 $sample_mark=join "\#",@mark;
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
125
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
126
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
127 #read_config();
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
128
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
129 trim_adapter_and_filter();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
130
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
131 my $filter_out=$dir."preProcess\/"."collapse_reads_out.fa";## raw clean data
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
132 my $data2=$filter_out; ### mirbase not mapped reads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
133 my $data3=$dir."\/rfam_match\/rfam_not_mapped\.fa"; ### rfam not mapped reads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
134 my $bed=$dir."cluster\/"."sample\.bed";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
135 my $read=$dir."cluster\/"."sample_reads\.cluster";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
136 my $read_txt=$dir."cluster\/"."cluster\.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
137 my $rpkm=$dir."cluster\/"."sample_rpkm\.cluster";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
138 my $preprocess;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
139 my $cluster_file;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
140 my $annotate_dir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
141 my $deg_dir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
142 my %id;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
143 for (my $i=0;$i<@mark ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
144 $id{$mark[$i]}=$i+4;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
145 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
146 group_and_filter(); #collapse reads to tags
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
147
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
148 rfam();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
149
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
150 my @map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
151 my $map_tag=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
152 genome();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
153
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
154 bwt2bed();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
155
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
156 cluster();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
157
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
158 quantify();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
159
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
160 phase();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
161
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
162 if (defined($options{'nat'})&&defined($options{'repeat'})) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
163 class();
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
164 }
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
165 else{
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
166 get_genelist();
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
167 }
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
168
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
169 annotate();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
170
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
171 genome_length();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
172
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
173 plot();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
174
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
175 my @pairdir;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
176 if (defined($options{'deg'})) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
177 dec();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
178 infor_merge();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
179 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
180 html();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
181 print "\ncluster program end:";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
182 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
183 ############################sub program###################################################
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
184 sub make_dir_tmp{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
185
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
186 #make temporary directory
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
187 if(not -d "$workdir\/cluster_runs_$time"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
188 mkdir("$workdir\/cluster_runs_$time");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
189 mkdir("$workdir\/cluster_runs_$time\/ref\/");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
190 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
191
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
192 $dir="$workdir\/cluster_runs_$time\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
193 print STDERR "mkdir $dir\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
194 return;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
195 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
196
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
197 #sub read_config{
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
198 # open IN,"<$config";
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
199 # while (my $aline=<IN>) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
200 # chomp $aline;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
201 # my @tmp=split/\t/,$aline;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
202 # push @filein,$tmp[0];
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
203 # push @mark,$tmp[1];
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
204 # }
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
205 # close IN;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
206 # if (@filein != @mark) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
207 # die "Maybe config file have some wrong!!!\n";
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
208 # }
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
209 # $sample_number=@mark;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
210 # $mark=join "\t",@mark;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
211 # $sample_mark=join "\#",@mark;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
212 #}
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
213
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
214
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
215 sub trim_adapter_and_filter{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
216 my $time=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
217 $preprocess=$dir."preProcess/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
218 mkdir $preprocess;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
219 my $can_use_threads = eval 'use threads; 1';
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
220 if ($can_use_threads) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
221 # Do processing using threads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
222 my @filein1=@filein; my @mark1=@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
223 while (@filein1>0) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
224 my @thrs; my @res;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
225 for (my $i=0;$i<$t ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
226 last if(@filein1==0);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
227 my $in=shift @filein1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
228 my $out=shift @mark1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
229 push @clip,$dir."preProcess\/$out\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
230 $thrs[$i]=threads->create(\&clips,$in,$out);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
231 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
232 for (my $i=0;$i<@thrs;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
233 $res[$i]=$thrs[$i]->join();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
234 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
235 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
236 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
237 else {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
238 # Do not processing using threads
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
239 for (my $i=0;$i<@filein ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
240 my $in=$filein[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
241 my $out=$mark[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
242 push @clip,$dir."preProcess\/$out\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
243 &clips($in,$out);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
244 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
245 }
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 clips{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
249 my ($filein,$fileout)=@_;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
250 my $adapter=$dir."preProcess\/$fileout\_clip\.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
251 if($format eq "fq" || $format eq "fastq"){
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
252 my $clip=`fastx_clipper -a $adpter -M 6 -Q $phred_qv -i $filein -o $adapter`;
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
253 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
254 if($format eq "fa" || $format eq "fasta"){
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
255 my $clip=`fastx_clipper -a $adpter -M 6 -i $filein -o $adapter`;
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
256 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
257 #my $clean=$dir."preProcess\/$fileout\_clean.fq";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
258 #my $filter=`filterReadsByLength.pl -i $adapter -o $clean -min 18 -max 40 `;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
259 return $fileout;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
260 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
261
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
262 sub group_and_filter{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
263 #my ($ins,$data)=@_;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
264 my @ins=@clip;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
265 my $str="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
266 my $group_out_file=$dir."preProcess\/"."collapse_reads.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
267 #print "$$ins[0]\t$$ins[0]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
268 for (my $i=0;$i<@clip;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
269 $str .="-i $clip[$i] ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
270 #print "$$ins[$i]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
271 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
272 my $group=`perl $path\/collapseReads2Tags.pl $str -mark seq -o $group_out_file -format $format`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
273 print "perl $path\/collapseReads2Tags.pl $str -mark seq -o $group_out_file -format $format\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
274
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
275 my $l_out=$dir."preProcess\/"."collapse_reads_18-40.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
276 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
277 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
278 my $cout_f=`perl $path\/filterReadsByCount.pl -i $l_out -o $filter_out -mark $sample_mark`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
279 print "perl $path\/filterReadsByCount.pl -i $l_out -o $filter_out -mark $sample_mark\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
280 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
281 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
282
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
283 sub rfam{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
284 if (defined $options{'idx2'}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
285 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
286 }else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
287 system("perl $path\/rfam.pl -i $data2 -ref $options{rfam} -v $mis_rfam -p $t -o $dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
288 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
289 my $tag=join "\\;" ,@mark;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
290 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
291 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
292 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
293 sub genome{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
294 if(defined $options{'idx'}){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
295 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
296 }else{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
297 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
298 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
299 #=================== mapping sta ===================================================
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
300 my $map_file=$dir."genome_match\/genome_mapped\.fa";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
301 open (MAP,"<$map_file")||die"$!";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
302 print "\n#each sample mapping reads sta:\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
303 print "#$mark\ttotal\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
304 while (my $ID=<MAP>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
305 chomp $ID;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
306 my @tmp=split/\:/,$ID;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
307 my @exp=split/\_/,$tmp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
308 $exp[-1] =~ s/^x//;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
309 for (my $i=0;$i<@exp ;$i++) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
310 $map_read[$i]+=$exp[$i];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
311 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
312 $map_tag++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
313 my $seq=<MAP>;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
314 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
315 my $map_read=join"\t",@map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
316 print "$map_read\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
317 print "#total mapped tags:$map_read\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
318 close MAP;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
319 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
320 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
321
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
322 sub bwt2bed{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
323 $cluster_file=$dir."cluster\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
324 mkdir ("$cluster_file");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
325 print "sam file changed to bed file\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
326 my ($file) = $dir."genome_match\/genome_mapped\.bwt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
327
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
328 my $sam2bed=`perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed `;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
329 print "perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
330 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
331 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
332
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
333 sub cluster{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
334 print "tags is ready to merged clusters\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
335 my ($file) =$bed;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
336 if ($cluster_mothod eq "F") {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
337 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
338 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
339 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
340 elsif($cluster_mothod eq "T"){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
341 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
342 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
343 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
344 else{print "\-p is wrong!\n\n";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
345 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
346 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
347
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
348
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
349 sub quantify{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
350 print "clusters is ready to quantified\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
351 my @depth=@map_read;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
352 pop @depth;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
353 my $depth=join ",",@depth;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
354 my $quantify=`perl $path\/quantify.pl -i $read -d $depth -o $rpkm`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
355 print "perl $path\/quantify.pl -i $read -d $depth -o $rpkm\n\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
356 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
357 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
358
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
359 sub phase{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
360 $annotate_dir=$dir."annotate\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
361 mkdir ("$annotate_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
362 print "clusters is to predict phase siRNA\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
363 my $phase=`perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
364 print "perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out\n\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
365 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
366 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
367
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
368 sub class{
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
369 print "clusters is ready to annotate by sources\n\n";
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
370 my $nat=$options{'nat'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
371 my $repeat=$options{'repeat'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
372 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
373 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
374 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
375
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
376 sub annotate{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
377 print "clusters is ready to annotate by gff file\n\n";
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
378 my $file;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
379 if (defined($options{'nat'})&&defined($options{'repeat'})) {
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
380 $file="$annotate_dir\/sample_class.anno";
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
381 }
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
382 else{
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
383 $file=$rpkm;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
384 }
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
385 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
386 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
387 return 0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
388 }
5
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
389 sub get_genelist{
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
390
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
391 my $get_genelist=`perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt`;
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
392 print "perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt";
f466394ee1fd Uploaded
big-tiandm
parents: 0
diff changeset
393 }
0
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
394
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
395 sub dec{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
396 print "deg reading\n\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
397 my $deg_file=$options{'deg'};
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
398 open IN,"<$deg_file";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
399 my @deg;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
400 my $s=0;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
401 while (my $aline=<IN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
402 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
403 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
404 $deg[$s]=$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
405 my @ea=split/\s+/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
406 push @pairdir,"$ea[0]_VS_$ea[1]\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
407 #print "$deg[$s]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
408 $s++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
409 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
410 close IN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
411 $deg_dir=$dir."deg\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
412 mkdir ("$deg_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
413 my $max_process = 10;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
414 my $pm = new Parallel::ForkManager( $max_process );
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
415 my $number=@deg-1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
416 foreach(0..$number){
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
417 $pm->start and next;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
418 &dec_pel($deg[$_]);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
419 $pm->finish;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
420 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
421 $pm->wait_all_children;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
422 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
423
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
424 sub dec_pel{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
425 print "start:\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
426 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
427 my $sample=shift(@_);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
428 my @each=split/\s+/,$sample;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
429 print "$each[0]\t$each[1]\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
430 my $deg_sample_dir=$deg_dir."$each[0]_VS_$each[1]\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
431 mkdir ("$deg_sample_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
432 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
433 my $time2=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
434 print "end:\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
435 Time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
436 sleep 1;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
437 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
438
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
439 sub infor_merge{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
440 my ($input,$mark);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
441 foreach (@pairdir) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
442 print "@pairdir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
443 $mark.=" -mark $_ ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
444 $input.=" -i $dir/deg\/$_\/output_score\.txt ";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
445 print "$input\n$mark\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
446 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
447 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
448 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
449 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
450
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
451 sub genome_length{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
452 my $length=`perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
453 print "perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length\n\n"
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
454
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
455 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
456
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
457 sub plot{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
458 my $plot_file="$dir\/plot\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
459 mkdir ("$plot_file");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
460 my $genome_plot="$dir\/plot\/genome\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
461 mkdir ("$genome_plot");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
462 #genome cluster
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
463 my $span=defined($options{span})?$options{span}:50000;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
464 foreach (1..$sample_number) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
465 my $mark=$mark[$_-1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
466 my $cen="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
467 if (defined $options{cen}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
468 $cen="-cen $options{cen}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
469 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
470 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
471 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
472 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
473
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
474 my $chr_plot_dir="$dir\/plot\/chr\/";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
475 mkdir("$chr_plot_dir");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
476 my %chr;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
477 open LEN,"<$dir\/ref\/genome\.length";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
478 while (my $aline=<LEN>) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
479 next if($aline=~/^\#/);
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
480 chomp $aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
481 my @temp=split/\t/,$aline;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
482 $chr{$temp[0]}=$temp[1];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
483 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
484 close LEN;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
485 foreach my $chr (sort keys %chr) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
486 my $cen="";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
487 if (defined $options{cen}) {
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
488 $cen="-cen $options{cen}";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
489 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
490 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
491 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
492 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
493 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
494
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
495 sub html{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
496 my $pathfile="$dir/path.txt";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
497 open PA,">$pathfile";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
498 print PA "$config\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
499 print PA "$preprocess\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
500 print PA "$dir"."rfam_match\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
501 print PA "$dir"."genome_match\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
502 print PA "$cluster_file\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
503 print PA "$annotate_dir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
504 print PA "$deg_dir\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
505 close PA;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
506 my $html=`perl $path\/html.pl -i $pathfile -format $format -o $dir/result.html`;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
507 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
508
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
509 sub Time{
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
510 my $time=time();
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
511 my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6];
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
512 $month++;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
513 $year+=1900;
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
514 if (length($sec) == 1) {$sec = "0"."$sec";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
515 if (length($min) == 1) {$min = "0"."$min";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
516 if (length($hour) == 1) {$hour = "0"."$hour";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
517 if (length($day) == 1) {$day = "0"."$day";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
518 if (length($month) == 1) {$month = "0"."$month";}
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
519 print "$year-$month-$day $hour:$min:$sec\n";
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
520 return("$year-$month-$day-$hour-$min-$sec");
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
521 }
07745c0958dd Uploaded
big-tiandm
parents:
diff changeset
522 #################################################################################