annotate snpEff/SnpEff.pl @ 23:a1ab979f4551 draft

Uploaded
author dereeper
date Mon, 23 Mar 2015 05:52:17 -0400
parents 13cff72ec2d3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
2
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
3 use strict;
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
4 use Getopt::Long;
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
5
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
6 my $usage = qq~Usage:$0 <args> [<opts>]
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
7 where <args> are:
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
8 -i, --input <input VCF>
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
9 -o, --output <output>
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
10 -g, --gff <GFF annotation>
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
11 -f, --fasta <Fasta of chromosomes>
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
12 -h, --html <HTML output>
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
13 ~;
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
14 $usage .= "\n";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
15
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
16 my ($input,$output,$gff,$fasta,$html);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
17
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
18
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
19 GetOptions(
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
20 "input=s" => \$input,
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
21 "output=s" => \$output,
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
22 "gff=s" => \$gff,
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
23 "fasta=s" => \$fasta,
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
24 "html=s" => \$html
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
25 );
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
26
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
27
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
28 die $usage
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
29 if ( !$input || !$output || !$fasta || !$gff || !$html);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
30
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
31
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
32 if (!-e $gff){
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
33 die "Error: GFF input does not exist\n"
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
34 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
35 if (!-e $fasta){
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
36 die "Error: Fasta input does not exist\n"
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
37 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
38
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
39 #my $SNPEFF_PATH = "/usr/local/bioinfo/galaxy/galaxy_dist/tools/SNiPlay/SnpEff/snpEff";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
40 my $SNPEFF_PATH = $ENV{SNPEFF_JAR_PATH};
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
41
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
42
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
43 my $session = $$;
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
44 mkdir($session);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
45 mkdir("$session/data");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
46 mkdir("$session/data/genomes");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
47 mkdir("$session/data/myspecies");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
48
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
49 system("cp -rf $fasta $session/data/genomes/myspecies.fa");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
50 system("cp -rf $gff $session/data/myspecies/genes.gff");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
51
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
52 open(my $C,"$SNPEFF_PATH/snpEff.config");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
53 open(my $C2,">$session/snpEff.config");
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
54 while(<$C>)
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
55 {
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
56 if (/data_dir/)
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
57 {
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
58 print $C2 "data_dir = ./data\n";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
59 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
60 elsif (/^genomes/)
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
61 {
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
62 print $C2 "genomes : \\n";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
63 print $C2 "myspecies, myspecies \\n";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
64 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
65 else
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
66 {
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
67 print $C2 $_;
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
68 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
69 }
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
70 print $C2 "myspecies.genome : myspecies\n";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
71 close($C);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
72 close($C2);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
73
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
74
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
75 my $build_cmd = "java -jar $SNPEFF_PATH/snpEff.jar build -c $session/snpEff.config -gff3 myspecies";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
76 system($build_cmd);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
77
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
78 my $eff_cmd = "java -jar $SNPEFF_PATH/snpEff.jar eff -c $session/snpEff.config -o vcf -no-downstream -no-upstream myspecies -s $html $input >$output";
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
79 system($eff_cmd);
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
80
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
81
13cff72ec2d3 Uploaded
dereeper
parents:
diff changeset
82 system("rm -rf $session");