my ($fset,$contig) = @_;
my @f = $fset->sub_SeqFeature;
if ($f[0]->strand == 1) {
@f = sort {$a->start <=> $b->start} @f;
} else {
@f = sort {$b->start <=> $a->start} @f;
}
my @transcripts;
my $startphase = 0;
while ($startphase < 3) {
my $endphase = $startphase;
push(@transcripts,$transcript);
$transcript->temporary_id($contig->id . "." . $endphase);
my $count = 1;
my @exons;
foreach my $f (@f) {
#print "exon seqname = ".$f->seqname."\n";
#print STDERR "exon ".$f->gffstring."\n";
push(@exons,$exon);
$exon->seqname($f->seqname);
$exon->temporary_id ($contig->id . ".$count");
$exon->contig ($contig);
$exon->start ($f->start);
$exon->end ($f->end );
$exon->strand ($f->strand);
$exon->slice($contig);
$exon->phase ($endphase);
$exon->end_phase( ($exon->phase + $exon->length)%3 );
#$exon->score ($f->score);
# $exon->p_value ($f->p_value);
$endphase = $exon->end_phase;
$transcript->add_Exon($exon);
$count++;
#print STDERR "Added exon start " . $exon->start . " end " . $exon->end . " strand " . $exon->strand . " score " . $exon->score . " pvalue " . $exon->p_value . "\n";
}
my $contig_id = "";
my $fset_id = "";
if (defined($contig->id)) {
$contig_id = $contig->id;
}
if (defined($fset->id)) {
$fset_id = $fset->id;
}
$translation->temporary_id($contig_id . "." . $fset_id);
$translation->end ($exons[$#exons]->end - $exons[$#exons]->start + 1);
$translation->start_Exon($exons[0]);
$translation->end_Exon ($exons[$#exons]);
$transcript->translation($translation);
# print STDERR "Phase $startphase " . $transcript->translate->seq . "\n";
$startphase++;
}
#print "finshed fset2transcript_3frame\n";
return @transcripts;
}