diff siRNA.pl @ 5:f466394ee1fd draft

Uploaded
author big-tiandm
date Thu, 23 Oct 2014 22:08:09 -0400
parents 07745c0958dd
children
line wrap: on
line diff
--- a/siRNA.pl	Thu Oct 23 22:07:41 2014 -0400
+++ b/siRNA.pl	Thu Oct 23 22:08:09 2014 -0400
@@ -12,7 +12,7 @@
 print "
 #####################################
 #                                   # 
-#    sRNA cluster                   # 
+#          sRNA cluster             # 
 #                                   #
 #####################################
 ";
@@ -57,13 +57,17 @@
 
 my %options;
 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");
+#print help if that option is used
+if($options{h}){die $usage;}
 
-my @inputfiles=@{$opts{'i'}};
-my @inputtags=@{$opts{'tag'}};
+my @filein=@{$options{'i'}};
+my @mark=@{$options{'tag'}};
 
 #my $config=$options{'i'};
 my $genome_fa=$options{'g'};
 my $gff=$options{'f'};
+
+
 ##########################################################################################
 my $predir=`pwd`;
 chomp $predir;
@@ -91,10 +95,8 @@
 #}
 
 my $adpter="ATCTCGTATG";  #adapter
-if (defined $opts{'a'}) {$a=$opts{'a'};}
+if (defined $options{'a'}) {$adpter=$options{'a'};}
 
-#print help if that option is used
-if($options{h}){die $usage;}
 
 my $phred_qv=64;
 my $sample_number;
@@ -104,18 +106,25 @@
 my $time=Time();
 make_dir_tmp();
 
-my (@filein,@mark,@clip);
+my @clip;
 my $mark;
 my $sample_mark;
 
-my $config=$workdir."/input_config";
+my $config=$dir."/input_config";
 open CONFIG,">$config";
-	for (my $i=0;$i<@inputfiles;$i++) {
-		print CONFIG $inputfiles[$i],"\t",$inputtags[$i],"\n";
+	for (my $i=0;$i<@filein;$i++) {
+		print CONFIG $filein[$i],"\t",$mark[$i],"\n";
 	}
 close CONFIG;
+if (@filein != @mark) {
+	die "Maybe config file have some wrong!!!\n";
+}
+$sample_number=@mark;
+$mark=join "\t",@mark;
+$sample_mark=join "\#",@mark;
 
-read_config();
+
+#read_config();
 
 trim_adapter_and_filter();
 
@@ -150,7 +159,12 @@
 
 phase();
 
-class();
+if (defined($options{'nat'})&&defined($options{'repeat'})) {
+	class();
+}
+else{
+	get_genelist();
+}
 
 annotate();
 
@@ -180,22 +194,22 @@
 	return;
 }
 
-sub read_config{
-	open IN,"<$config";
-	while (my $aline=<IN>) {
-		chomp $aline;
-		my @tmp=split/\t/,$aline;
-		push @filein,$tmp[0];
-		push @mark,$tmp[1];
-	}
-	close IN;
-	if (@filein != @mark) {
-		die "Maybe config file have some wrong!!!\n";
-	}
-	$sample_number=@mark;
-	$mark=join "\t",@mark;
-	$sample_mark=join "\#",@mark;
-}
+#sub read_config{
+#	open IN,"<$config";
+#	while (my $aline=<IN>) {
+#		chomp $aline;
+#		my @tmp=split/\t/,$aline;
+#		push @filein,$tmp[0];
+#		push @mark,$tmp[1];
+#	}
+#	close IN;
+#	if (@filein != @mark) {
+#		die "Maybe config file have some wrong!!!\n";
+#	}
+#	$sample_number=@mark;
+#	$mark=join "\t",@mark;
+#	$sample_mark=join "\#",@mark;
+#}
 
 
 sub trim_adapter_and_filter{
@@ -235,10 +249,10 @@
 	my ($filein,$fileout)=@_;
 	my $adapter=$dir."preProcess\/$fileout\_clip\.fq";
 	if($format eq "fq" || $format eq "fastq"){
-		my $clip=`$path\/fastx_clipper -a $adpter -M 6  -Q $phred_qv -i $filein -o $adapter`;
+		my $clip=`fastx_clipper -a $adpter -M 6  -Q $phred_qv -i $filein -o $adapter`;
 	}
 	if($format eq "fa" || $format eq "fasta"){
-		my $clip=`$path\/fastx_clipper -a $adpter -M 6 -i $filein -o $adapter`;
+		my $clip=`fastx_clipper -a $adpter -M 6 -i $filein -o $adapter`;
 	}
 	#my $clean=$dir."preProcess\/$fileout\_clean.fq";
 	#my $filter=`filterReadsByLength.pl -i $adapter -o $clean -min 18 -max 40 `;
@@ -352,7 +366,7 @@
 }
 
 sub class{
-	print "clusters is ready to annotate by source\n\n";
+	print "clusters is ready to annotate by sources\n\n";
 	my $nat=$options{'nat'};
 	my $repeat=$options{'repeat'};
 	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`;
@@ -361,11 +375,22 @@
 
 sub annotate{
 	print "clusters is ready to annotate by gff file\n\n";
-	my $file="$annotate_dir\/sample_class.anno";
+	my $file;
+	if (defined($options{'nat'})&&defined($options{'repeat'})) {
+		$file="$annotate_dir\/sample_class.anno";
+	}
+	else{
+		$file=$rpkm;
+	}
 	my $annotate=`perl $path\/Annotate.pl -i $file -g $dir\/ref\/genelist.txt -d $up_down_dis -o $annotate_dir\/sample_c_p.anno`;
 	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";
 	return 0;
 }
+sub get_genelist{
+
+	my $get_genelist=`perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt`;
+	print "perl $path\/get_genelist.pl -i $gff -o $dir\/ref\/genelist.txt";
+}
 
 sub dec{
 	print "deg reading\n\n";