start fixing test for multi cat phenotype upload.
[sgn.git] / lib / CXGN / Transcript / DrawContigAlign / ContigAlign.pm
blob990e981ad873cdc88997d9a15893844adccaaee9
1 =head1 NAME
3 CXGN::Transcript::DrawContigAlign::ContigAlign - stores alignment data for a strand in a unigene.
5 =head1 SYNOPSIS
7 Initialize it with all of the relevant values and use accessors to access the data.
9 $contigAlign = ContigAlign->new('Source ID', 'Sequence ID', '+', 10, 400, 20, 33, 1);
10 $sourceID = $contigAlign->sourceID; #returns 'Source ID'
12 =head1 DESCRIPTION
14 ContigAlign stores alignment data for a strand in a unigene, primarily for use with CXGN::Transcript::DrawContigAlign, which uses it to store data that is being used to produce a graph.
16 =head1 AUTHORS
18 Rafael Lizarralde <xarbiogeek@gmail.com> (July 2009)
20 =head1 MEMBER FUNCTIONS
22 =head2 constructor C<new>
24 =over 10
26 =item Usage:
28 $contigAlign = CXGN::Transcript::DrawContigAlign::ContigAlign->new('Source ID', 'Sequence ID', '+', 10, 400, 20, 33, 1);
30 =item Ret:
32 a CXGN::Transcript::DrawContigAlign::ContigAlign object
34 =item Args:
36 =over 18
38 =item Str $sourceID
40 the ID tag for the strand
42 =item Str $sequenceID
44 the ID tag for the unigene
46 =item Str $strand
48 identifier if the strand is complementary or not (if not, it should be '+')
50 =item Int $startLoc
52 the base pair in the unigene's sequence at which this strand starts
54 =item Int $endLoc
56 the base pair at which this strand ends
58 =item Int $startTrim
60 the number of base pairs at the beginning that do not match
62 =item Int $endTrim
64 the number of base pairs at the end that do not match
66 =item Bool $highlight
68 whether or not the strand should be highlighted on the graph
70 =back
72 =back
74 =head2 accessors:
76 =over 12
78 =item sourceID
80 returns a string with the ID tag for the strand
82 =item sequenceID
84 returns a string with the ID tag for the unigene
86 =item strand
88 returns a string with an identifier indicating whether the strand is complementary or not
90 =item startLoc
92 returns an integer indicating the base pair at which this strand starts
94 =item endLoc
96 returns an integer indicating the base pair at which this strand ends
98 =item startTrim
100 returns an integer indicating the number of base pairs that do not match at the start
102 =item endTrim
104 returns an integer indicating the number of base pairs that do not match at the end
106 =item start
108 returns an integer indicating the first matching base pair (startLoc + startTrim)
110 =item end
112 returns an integer indicating the last matching base pair (endLoc - endTrim)
114 =item highlight
116 returns a boolean indicating whether this strand is highlighted
118 =back
120 =cut
122 package CXGN::Transcript::DrawContigAlign::ContigAlign;
124 use Moose;
125 use MooseX::Method::Signatures;
127 has sourceID => (is => 'ro', isa => 'Str');
128 has sequenceID => (is => 'ro', isa => 'Str');
129 has strand => (is => 'ro', isa => 'Str');
130 has startLoc => (is => 'ro', isa => 'Int');
131 has endLoc => (is => 'ro', isa => 'Int');
132 has startTrim => (is => 'ro', isa => 'Int');
133 has endTrim => (is => 'ro', isa => 'Int');
134 has start => (is => 'ro', isa => 'Int');
135 has end => (is => 'ro', isa => 'Int');
136 has highlight => (is => 'ro', isa => 'Bool', default => undef);
138 sub BUILDARGS {
139 my $class = shift;
140 if(@_ == 8) {
141 return { sourceID => $_[0], sequenceID => $_[1], strand => $_[2],
142 startLoc => $_[3], endLoc => $_[4], startTrim => $_[5], endTrim => $_[6],
143 start => $_[3] + $_[5], end => $_[4] - $_[6], highlight => $_[7],
145 } else { return $class->SUPER::BUILDARGS(@_); }
148 =head2 accessor C<compare>
150 =over 10
152 =item Usage:
154 print "contig1 is less than contig2!" if($contig1->compare($contig2) < 0);
156 =item Ret:
158 a negative value if the instance from which the method is called is less than the argument, zero if they are equal, and a positive value if the argument is greater
160 =item Args:
162 $other another ContigAlign object
164 =back
166 =cut
168 method compare (CXGN::Transcript::DrawContigAlign::ContigAlign $other!) {
169 ($self->start - $other->start != 0) ?
170 return $self->start - $other->start:
171 return $self->end - $other->end;
173 no Moose;
174 __PACKAGE__->meta->make_immutable;
175 return 1;
177 =head1 SEE ALSO
179 This is primarily used by CXGN::Transcript::DrawContigAlign, which, in turn, is used by CXGN::Transcript::Unigene.
180 DrawContigAlign also uses CXGN::Transcript::DrawContigAlign::DepthData and CXGN::Transcript::DrawContigAlign::Pane.
182 =cut