Skip to content

Instantly share code, notes, and snippets.

@epaule
Last active September 27, 2015 05:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epaule/1216188 to your computer and use it in GitHub Desktop.
Save epaule/1216188 to your computer and use it in GitHub Desktop.
Cufflinks FTP to Agustus hints GFF conversion (exon|intron|ep)
#!/usr/bin/env perl
#
# convert cufflinks GTF into a Augustus hintfile
#
# seq source ep|exon|intron start stop score +/- phase grp=ID; src=E
my %transcripts;
while(<>){
next unless /Cufflinks\s+exon.*transcript_id/;
s/"//g;
chomp;
my @c = split;
push @{$transcripts{$c[11]}},{seq=>$c[0],name => $c[11],start => $c[3],stop => $c[4],strand => $c[6]};
}
while(my($k,$v)=each %transcripts){
my @exons = sort {$a->{start} <=> $b->{stop}} @$v; # get them in the correct order ... just in case
for(my $i=0;$i<scalar(@exons);$i++){
my $ex=$exons[$i];
unless($i == 0){
my %intron = %$ex;
$intron{start}=$exons[$i-1]->{stop}+1;
$intron{stop} =$ex->{start}-1;
print_gff(\%intron,'intron');
}
if($i == 0 || $i==scalar(@exons)-1){
print_gff($ex,'ep');
}
else{
print_gff($ex,'exon');
}
}
}
sub print_gff{
my ($e,$source)=@_;
printf "%s\tCufflinks\t$source\t%d\t%d\t.\t%s\t.\tgrp=%ssrc=W\n",$e->{seq},$e->{start},$e->{stop},$e->{strand},$e->{name};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment