annotate siRNA_pipeline.pl @ 50:7b5a48b972e9 draft

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