annotate siRNA.pl @ 0:87fe81de0931 draft default tip

Uploaded
author bigrna
date Sun, 04 Jan 2015 02:47:25 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
1 #!/usr/bin/perl -w
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
2 my $version=1.00;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
3 use strict;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
4 use warnings;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
5 use Getopt::Long;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
6 use Getopt::Std;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
7 use threads;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
8 #use threads::shared;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
9 use Parallel::ForkManager;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
10 #use lib '/leofs/biotrans/chentt/perl_module/';
87fe81de0931 Uploaded
bigrna
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
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
12 print "
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
13 #####################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
14 # #
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
15 # sRNA cluster #
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
16 # #
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
17 #####################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
18 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
19 ###########################################################################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
20 my $usage="$0
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
21 Options:
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
22 -i input file# fasta
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
23 -config input file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
24 -g genome file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
25 -f gff file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
26
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
27 -o workdir file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
28 -path script path
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
29 -t int, number of threads [1]
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
30 -format fastq, fq, fasta or fa
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
31 -idx string, genome file index, file-prefix #(must be indexed by bowtie-build) The parameter
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
32 string must be the prefix of the bowtie index. For instance, if
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
33 the first indexed file is called 'h_sapiens_37_asm.1.ebwt' then
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
34 the prefix is 'h_sapiens_37_asm'.##can be null
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
35 -mis int number of allowed mismatches when mapping reads to genome, default 0
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
36
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
37 -n int max hits number,default 25; used in genome alignment
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
38 -d int distance of tag to merged a cluster; default 100
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
39 -p cluster method F :conventional default is F
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
40 T :NIBLES
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
41 -l int the length of the upstream and downstream,default 1000;used in position annotate
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
42
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
43 -nat natural antisense transcripts file
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
44 -repeat repeat information file out of Repeatmasker
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
45 -deg file config of de sample
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
46 -cen centromere file input
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
47 -span plot span, default 50000
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
48 ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
49
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
50 my %options;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
51 GetOptions(\%options,"i:s","config=s","g=s","f=s","o=s","path:s","p=s","format=s","nat:s","repeat:s","deg:s","n:i","mis:i","t:i","d:i","l:i","idx:s","cen:s","span:s","h");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
52 #print help if that option is used
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
53 if($options{h}){die $usage;}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
54
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
55 my $filein=$options{'i'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
56
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
57 #my $config=$options{'i'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
58 my $genome_fa=$options{'g'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
59 my $gff=$options{'f'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
60
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
61
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
62 ##########################################################################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
63 my $predir=`pwd`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
64 chomp $predir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
65 my $workdir=defined($options{'o'}) ? $options{'o'}:$predir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
66
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
67 my $path=$options{'path'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
68
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
69 my $t=defined($options{'t'})? $options{'t'}:1; #threads number
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
70
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
71 my $mis=defined $options{'mis'} ? $options{'mis'}:0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
72
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
73
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
74 my $hit=defined $options{'n'}?$options{'n'}:25;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
75
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
76 my $distance_of_merged_tag=defined $options{'d'} ? $options{'d'}:100;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
77
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
78 my $up_down_dis=defined $options{'l'} ?$options{'l'}:1000;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
79
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
80 my $cluster_mothod=defined $options{'p'}?$options{'p'}:"F";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
81
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
82 my $format=$options{'format'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
83 #if ($format ne "fastq" && $format ne "fq" && $format ne "fasta" && $format ne "fa") {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
84 # die "Parameter \"-format\" is error! Parameter is fastq, fq, fasta or fa\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
85 #}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
86
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
87
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
88
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
89 my $sample_number;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
90 my ($dir,$dir_tmp);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
91 ################################ MAIN ##################################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
92 print "\ncluster program start:";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
93 my $time=Time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
94 make_dir_tmp();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
95
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
96 my $mark;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
97 my $sample_mark;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
98
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
99 my $config=$options{'config'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
100 my (@filein,@mark);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
101 &read_config();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
102 $sample_number=@mark;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
103 $mark=join "\t",@mark;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
104 $sample_mark=join "\#",@mark;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
105
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
106
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
107
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
108 my $data3=$filein; ### rfam not mapped reads
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
109 genome();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
110
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
111 my $bed=$dir."cluster\/"."sample\.bed";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
112 my $read=$dir."cluster\/"."sample_reads\.cluster";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
113 my $read_txt=$dir."cluster\/"."cluster\.txt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
114 my $rpkm=$dir."cluster\/"."sample_rpkm\.cluster";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
115 my $preprocess;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
116 my $cluster_file;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
117 my $annotate_dir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
118 my $deg_dir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
119 my $plot_dir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
120 my %id;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
121 for (my $i=0;$i<@mark ;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
122 $id{$mark[$i]}=$i+4;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
123 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
124
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
125
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
126 my @map_read;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
127 my $map_tag=0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
128
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
129 bwt2bed();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
130
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
131 cluster();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
132
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
133 quantify();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
134
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
135 phase();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
136
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
137 if (defined($options{'nat'})&&defined($options{'repeat'})) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
138 class();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
139 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
140 else{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
141 get_genelist();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
142 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
143
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
144 annotate();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
145
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
146 genome_length();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
147
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
148 plot();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
149
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
150 my @pairdir;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
151 if (defined($options{'deg'})) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
152 dec();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
153 infor_merge();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
154 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
155 else{infor_merge_no_dec()}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
156 html();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
157 print "\ncluster program end:";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
158 Time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
159 ############################sub program###################################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
160 sub make_dir_tmp{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
161
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
162 #make temporary directory
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
163 if(not -d "$workdir\/cluster_runs"){
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
164 mkdir("$workdir\/cluster_runs");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
165 mkdir("$workdir\/cluster_runs\/ref\/");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
166 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
167
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
168 $dir="$workdir\/cluster_runs\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
169 #print STDERR "mkdir $dir\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
170 return;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
171 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
172
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
173 sub genome{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
174 if(defined $options{'idx'}){
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
175 system("perl $path\/matching.pl -i $data3 -g $genome_fa -v $mis -p $t -r $hit -o $dir -index $options{idx}") ;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
176 }else{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
177 system("perl $path\/matching.pl -i $data3 -g $genome_fa -v $mis -p $t -r $hit -o $dir ") ;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
178 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
179 #=================== mapping sta ===================================================
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
180 my $map_file=$dir."genome_match\/genome_mapped\.fa";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
181 open (MAP,"<$map_file")||die"$!";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
182 print "\n#each sample mapping reads sta:\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
183 print "#$mark\ttotal\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
184 while (my $ID=<MAP>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
185 chomp $ID;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
186 my @tmp=split/\:/,$ID;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
187 my @exp=split/\_/,$tmp[1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
188 $exp[-1] =~ s/^x//;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
189 for (my $i=0;$i<@exp ;$i++) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
190 $map_read[$i]+=$exp[$i];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
191 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
192 $map_tag++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
193 my $seq=<MAP>;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
194 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
195 my $map_read=join"\t",@map_read;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
196 print "$map_read\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
197 print "#total mapped tags:$map_read\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
198 close MAP;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
199 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
200 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
201
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
202 sub bwt2bed{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
203 $cluster_file=$dir."cluster\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
204 mkdir ("$cluster_file");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
205 print "sam file changed to bed file\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
206 my ($file) = $dir."genome_match\/genome_mapped\.bwt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
207
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
208 my $sam2bed=`perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed `;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
209 print "perl $path\/sam2Bed_bowtie.pl -i $file -mark $sample_mark -o $bed\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
210 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
211 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
212
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
213 sub cluster{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
214 print "tags is ready to merged clusters\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
215 my ($file) =$bed;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
216 if ($cluster_mothod eq "F") {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
217 my $cluster=`perl $path\/conventional.pl -i $file -d $distance_of_merged_tag -n $sample_number -mark $sample_mark -o $read -t $read_txt`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
218 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";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
219 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
220 elsif($cluster_mothod eq "T"){
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
221 my $cluster=`perl $path\/nibls.pl -f $file -m $distance_of_merged_tag -o $read -t $read_txt -k $sample_mark`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
222 print "Using nibls method\n perl $path\/nibls.pl -f $file -m $distance_of_merged_tag -o $read -t $dir\/cluster.txt -k $sample_mark\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
223 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
224 else{print "\-p is wrong!\n\n";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
225 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
226 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
227
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
228
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
229 sub quantify{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
230 print "clusters is ready to quantified\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
231 my @depth=@map_read;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
232 pop @depth;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
233 my $depth=join ",",@depth;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
234 my $quantify=`perl $path\/quantify_siRNA.pl -i $read -d $depth -o $rpkm`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
235 print "perl $path\/quantify_siRNA.pl -i $read -d $depth -o $rpkm\n\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
236 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
237 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
238
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
239 sub phase{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
240 $annotate_dir=$dir."annotate\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
241 mkdir ("$annotate_dir");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
242 print "clusters is to predict phase siRNA\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
243 my $phase=`perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
244 print "perl $path\/phased_siRNA.pl -i $read_txt -o $annotate_dir\/phase.out\n\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
245 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
246 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
247
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
248 sub class{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
249 print "clusters is ready to annotate by sources\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
250 my $nat=$options{'nat'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
251 my $repeat=$options{'repeat'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
252 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`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
253 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";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
254 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
255
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
256 sub annotate{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
257 print "clusters is ready to annotate by gff file\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
258 my $file;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
259 if (defined($options{'nat'})&&defined($options{'repeat'})) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
260 $file="$annotate_dir\/sample_class.anno";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
261 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
262 else{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
263 $file=$rpkm;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
264 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
265 my $annotate=`perl $path\/Annotate.pl -i $file -g $dir\/ref\/genelist.txt -d $up_down_dis -o $annotate_dir\/sample_c_p.anno`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
266 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";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
267 return 0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
268 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
269 sub get_genelist{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
270
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
271 my $get_genelist=`perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
272 print "perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
273 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
274 sub dec{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
275 print "deg reading\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
276 my $deg_file=$options{'deg'};
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
277 open IN,"<$deg_file";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
278 my @deg;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
279 my $s=0;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
280 while (my $aline=<IN>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
281 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
282 next if($aline=~/^\#/);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
283 $deg[$s]=$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
284 my @ea=split/\s+/,$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
285 push @pairdir,"$ea[0]_VS_$ea[1]\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
286 #print "$deg[$s]\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
287 $s++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
288 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
289 close IN;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
290 $deg_dir=$dir."deg\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
291 mkdir ("$deg_dir");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
292 my $max_process = 10;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
293 my $pm = new Parallel::ForkManager( $max_process );
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
294 my $number=@deg-1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
295 foreach(0..$number){
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
296 $pm->start and next;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
297 &dec_pel($deg[$_]);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
298 $pm->finish;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
299 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
300 $pm->wait_all_children;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
301 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
302
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
303 sub dec_pel{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
304 print "\n******************\nstart:\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
305 Time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
306 my $sample=shift(@_);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
307 my @each=split/\s+/,$sample;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
308 print "$each[0]\t$each[1]\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
309 my $deg_sample_dir=$deg_dir."$each[0]_VS_$each[1]\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
310 mkdir ("$deg_sample_dir");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
311 print "read: $read\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
312 print "deg_sample_dir: $deg_sample_dir\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
313 print "$id{$each[0]}\t$each[0]\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
314 print "$id{$each[1]}\t$each[1]\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
315 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
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
316 my $time2=time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
317 print "end:\n*************************\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
318 Time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
319 sleep 1;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
320 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
321
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
322 sub infor_merge{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
323 my ($input,$mark);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
324 foreach (@pairdir) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
325 print "@pairdir\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
326 $mark.=" -mark $_ ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
327 $input.=" -i $dir/deg\/$_\/output_score\.txt ";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
328 print "$input\n$mark\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
329 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
330 my $infor_merge=`perl $path\/SampleDEGseqMerge.pl $input $mark -f $annotate_dir\/sample_c_p.anno -n $sample_number -o $dir\/total.result `;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
331 print "perl $path\/SampleDEGseqMerge.pl $input $mark -f $annotate_dir\/sample_c_p.anno -n $sample_number -o $dir\/total.result\n\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
332 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
333
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
334 sub infor_merge_no_dec{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
335 my $infor_merge_no_dec=`cp $annotate_dir\/sample_c_p.anno $dir\/total.result`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
336 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
337
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
338 sub genome_length{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
339 my $length=`perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
340 print "perl $path\/count_ref_length.pl -i $genome_fa -o $dir\/ref\/genome\.length\n\n"
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
341
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
342 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
343
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
344 sub plot{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
345 $plot_dir="$dir\/plot\/";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
346 mkdir ("$plot_dir");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
347 my $span=defined($options{span})?$options{span}:50000;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
348 my $cen="";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
349 if (defined $options{cen}) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
350 $cen="-cen $options{cen}";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
351 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
352 my $plot=`perl $path/sRNA_plot.pl -c $rpkm -g $dir/ref/genelist.txt -span 50000 -mark $sample_mark -l $dir/ref/genome\.length $cen -o $plot_dir/cluster.html -out $plot_dir/cluster.txt `;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
353 "print perl $path/sRNA_plot.pl -c $rpkm -g $dir/ref/genelist.txt -span 50000 -mark $sample_mark -l $dir/ref/genome.length $cen -o $plot_dir/cluster.html -out $plot_dir/cluster.txt \n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
354
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
355 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
356
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
357 sub html{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
358 my $pathfile="$dir/path.txt";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
359 open PA,">$pathfile";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
360 print PA "$config\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
361 print PA "$preprocess\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
362 print PA "$dir"."rfam_match\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
363 print PA "$dir"."genome_match\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
364 print PA "$cluster_file\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
365 print PA "$annotate_dir\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
366 print PA "$plot_dir\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
367 if (defined($deg_dir)) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
368 print PA "$deg_dir\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
369 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
370 close PA;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
371 #my $html=`perl $path\/html.pl -i $pathfile -format $format -o $dir/result.html`;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
372 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
373
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
374 sub Time{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
375 my $time=time();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
376 my ($sec,$min,$hour,$day,$month,$year) = (localtime($time))[0,1,2,3,4,5,6];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
377 $month++;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
378 $year+=1900;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
379 if (length($sec) == 1) {$sec = "0"."$sec";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
380 if (length($min) == 1) {$min = "0"."$min";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
381 if (length($hour) == 1) {$hour = "0"."$hour";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
382 if (length($day) == 1) {$day = "0"."$day";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
383 if (length($month) == 1) {$month = "0"."$month";}
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
384 print "$year-$month-$day $hour:$min:$sec\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
385 return("$year-$month-$day-$hour-$min-$sec");
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
386 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
387 #################################################################################
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
388 sub read_config{
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
389 open CON,"<$config";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
390 while (my $aline=<CON>) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
391 chomp $aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
392 my @tmp=split/\t/,$aline;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
393 push @filein,$tmp[0];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
394 push @mark,$tmp[1];
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
395 #&check_rawdata($tmp[0]);
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
396 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
397 close CON;
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
398 if (@filein != @mark) {
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
399 #&printErr();
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
400 die "Maybe config file have some wrong!!!\n";
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
401 }
87fe81de0931 Uploaded
bigrna
parents:
diff changeset
402 }