annotate siRNA.pl @ 33:09fefe8db1d0 draft default tip

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