annotate siRNA.pl @ 14:36ba71d63988 draft

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