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