1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
package main;
our $SEE;
=head1 NAME
CDNA::Gene_obj_alignment_assembler;
=cut
=head1 DESCRIPTION
This package assembles multiple gene objs by assembling compatible sets of coordinates. This module inherits from the CDNA::Genome_based_cDNA_assembler module. Please see this inherited module for additional methods available.
=cut
package CDNA::Gene_obj_alignment_assembler;
use strict;
use base qw (CDNA::PASA_alignment_assembler);
use CDNA::CDNA_alignment;
=item new()
=over 4
B<Description:> Instantiate a new CDNA::Gene_obj_alignment_assembler object.
B<Parameters:> $seq_ref
$seq_ref is a scalar reference to the genomic sequence string.
B<Returns:> obj_ref
=back
=cut
sub new {
my $packagename = shift;
my $seqref = shift;
my $self = $packagename->SUPER::new();
$self->{sequence_ref} = $seqref;
bless ($self, $packagename);
return ($self);
}
=item assemble_genes()
=over 4
B<Description:> assembles a list of Gene_obj(s). Each of the Gene_objs
B<Parameters:> @Gene_obj
@Gene_obj is an array of gene objects created via the Gene_obj.pm module.
B<Returns:> @CDNA_alignments
The @CDNA_alignments array contains the list of CDNA::CDNA_alignment objects created based on the gene objects.
The CDNA_alignment accession is set to the Model_feat_name of the gene_obj. Retrieving the cDNA acc using the get_acc() method will allow a mapping back to the gene object. Also, the newly created CDNA_alignment objects that are returned should be in the same order as the inputed gene objects, so indexing should provide mapping info as well.
use the get_assemblies() function to fetch the merged genes.
=back
=cut
sub assemble_genes {
my $self = shift;
my @gene_objs = @_;
my @cDNA_alignments;
foreach my $gene_obj (@gene_objs) {
my $alignment_obj = $self->gene_obj_to_cdna_alignment($gene_obj);
push (@cDNA_alignments, $alignment_obj);
}
$self->assemble_alignments(@cDNA_alignments);
return (@cDNA_alignments);
}
=item gene_obj_to_cdna_alignment()
=over 4
B<Description:> method converts a Gene_obj to a CDNA::CDNA_alignment obj.
B<Parameters:> Gene_obj
B<Returns:> CDNA::CDNA_alignment
=back
=cut
sub gene_obj_to_cdna_alignment {
my $self = shift;
my $gene_obj = shift;
my @exons = $gene_obj->get_exons();
my %coords;
my @alignment_segments;
my $cdna_length = 0;
foreach my $exon (@exons) {
my ($end5, $end3) = $exon->get_coords();
my $alignment_seg = new CDNA::Alignment_segment($end5, $end3);
push (@alignment_segments, $alignment_seg);
$cdna_length += abs ($end3 - $end5) + 1;
}
my $alignment_obj = new CDNA::CDNA_alignment($cdna_length, \@alignment_segments, $self->{sequence_ref});
my $feat_name = $gene_obj->{Model_feat_name};
print "Gene has the following model feat_name: $feat_name\n" if $SEE;
$alignment_obj->set_acc($feat_name);
$alignment_obj->set_title($gene_obj->{com_name});
$alignment_obj->set_fli_status(1); #treat like a fli cdna
my $align_orient = $alignment_obj->get_spliced_orientation();
## Make sure strand is set correctly (should only matter for single exon genes).
if ($align_orient ne $gene_obj->{strand}) {
$alignment_obj->set_orientation($gene_obj->{strand});
$alignment_obj->set_spliced_orientation($gene_obj->{strand});
}
$alignment_obj->remap_cdna_segment_coords();
print $alignment_obj->toToken() ." " . $alignment_obj->get_acc() . "\n" if $SEE;
return ($alignment_obj);
}
1; #EOM
|