annotate 2.4/src/run_blat.pl @ 13:e3609c8714fb draft

Uploaded
author plus91-technologies-pvt-ltd
date Fri, 30 May 2014 03:37:55 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
1 #####################################################################################################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
2 #Purpose: To perform blat and organize blat
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
3 #Date: 07-19-2013
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
4 #####################################################################################################################################################
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
5 use Getopt::Long;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
6 #reading input arguments
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
7 &Getopt::Long::GetOptions(
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
8 'BLAT_PATH=s'=> \$blatpath,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
9 'REF_FILE=s'=> \$reffile,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
10 'INPUT_FILE=s' => \$inputfile,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
11 'OUTPUT_FILE=s' => \$outputfile,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
12 'MIN_SCORE=s'=> \$minScore,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
13 'MIN_IDENTITY=s'=> \$minidentity,
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
14 'BLAT_PORT=s'=>\$blatport
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
15 );
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
16 $blatpath =~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
17 $reffile=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
18 $inputfile=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
19 $outputfile=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
20 $minScore=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
21 $minidentity=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
22 $blatport=~ s/\s|\t|\r|\n//g;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
23 #input arguments
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
24
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
25 #checking for missing arguments
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
26 if($blatport eq "" || $blatpath eq "" || $reffile eq "" || $inputfile eq "" || $outputfile eq "" || $minScore eq "" || $minidentity eq "")
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
27 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
28 die "missing arguments\n USAGE : perl perl_blat.pl -BLAT_PORT <BLAT_PORT> -MIN_SCORE <MIN_SCORE> -MIN_IDENTITY <MIN_IDENTITY> -BLAT_PATH <PATH TO BLAT FOLDER> -REF_FILE <PATH TO 2bit file> -INPUT_FILE <INPUT CONFIG FILE> -OUTPUT_FILE <OUTPUT FILE>\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
29 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
30
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
31 #parsing the arguments
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
32
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
33 #unless(-d $outdir)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
34 #{
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
35 # system("mkdir -p $outdir");
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
36 #}
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
37 $status=`$blatpath/gfServer status localhost $blatport |wc -l`;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
38 chomp($status);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
39 $count = 0;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
40 while($status < 2 )
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
41 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
42 if($count > 0)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
43 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
44 $blatport = $blatport+int(rand(1000))+1;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
45 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
46 print "Starting the server\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
47 $sys ="$blatpath/gfServer start -canStop localhost $blatport $reffile &";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
48 print "$sys\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
49 system($sys);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
50 sleep(300);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
51 $status=`$blatpath/gfServer status localhost $blatport |wc -l`;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
52 chomp($status);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
53 $count++;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
54 if($count > 5)
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
55 {
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
56 die "something wrong with gfServer or command . Failed 5 times\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
57 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
58 }
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
59 print "querying \n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
60 $sys = "$blatpath/gfClient localhost $blatport / $inputfile $outputfile -minScore=$minScore -minIdentity=$minidentity";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
61 print "$sys\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
62 system($sys);
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
63 print "stoping the server\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
64 #$sys = "$blatpath/gfServer stop localhost $blatport";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
65 $pid = `ps|grep gfServer|head -1|cut -f1 -d ' '`;
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
66 $sys ="kill -9 $pid";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
67 print "$sys\n";
e3609c8714fb Uploaded
plus91-technologies-pvt-ltd
parents:
diff changeset
68 system($sys);