#!/usr/bin/perl -w # Runs the TranscriptToGenomicInfo tool to create big tables use strict; use Getopt::Long; my $in = undef; my $gatk = undef; my $ref = undef; my $out = undef; my $tmp = "/tmp"; GetOptions( "transcript=s" => \$in, "gatk=s" => \$gatk, "ref=s" => \$ref, "out=s" => \$out, "tmp=s" => \$tmp); if ( !$in || !$gatk || !$ref || !$out ) { print "Usage: createTranscriptToGenomicInfoTables.pl\n\t-transcript \t\n\t-gatk \t\t\n\t-ref \t\t\n\t-out \t\t\n\t-tmp \t\t\n"; print "Example: ./createTranscriptToGenomicInfoTables.pl\n\t-transcript test.foo\n\t-ref /seq/references/Homo_sapiens_assembly18/v0/Homo_sapiens_assembly18.fasta\n\t-gatk /humgen/gsa-scr1/ebanks/Sting_dev\n\t-out test.bar\n\t-tmp /broad/shptmp\n"; exit(1); } # generate a random number my $random_number = rand(); my $tmp_prefix = "$tmp/$random_number"; print "Writing temporary files to prefix: $tmp_prefix\n"; my $unsorted_table = "$tmp_prefix.unsorted.table"; # convert the file print "Converting the transcript table..."; my $cmd = "java -jar $gatk/dist/GenomeAnalysisTK.jar -T TranscriptToGenomicInfo -R $ref -B:transcripts,AnnotatorInputTable $in -o $unsorted_table -n name,proteinID"; system($cmd); # we need to sort the converted table now print "\nRe-sorting the table...\n"; open(SORTED, ">$out") or die "can't open $out: $!"; # write the header open(UNSORTED, "< $unsorted_table") or die "can't open $unsorted_table: $!"; my $line = ; print SORTED "$line"; close(UNSORTED); close(SORTED); $cmd = "grep haplotypeReference -v $unsorted_table | sort -n -k2 -T $tmp | $gatk/perl/sortByRef.pl --tmp $tmp - $ref.fai >> $out"; system($cmd); # clean up unlink $unsorted_table; print "\nDone!\n";