comparison SnpEff.pl @ 0:abde5b0387c8 draft

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