| 1 | # POD documentation - main docs before the code | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | GenOO::Data::DB::DBIC::Species::Schema::SampleResultBase::v3 - DBIC Result class for sequenced reads | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | # This class is not designed to be directly used in a DBIC schema because a | ||
| 10 | # table name is not defined. Rather it serves as a base class to be inherited | ||
| 11 | # by an actual result class to provide a common column structure. | ||
| 12 | |||
| 13 | # Offers more columns than GenOO::Data::DB::DBIC::Species::Schema::SampleResultBase::v1 | ||
| 14 | # Is the same as v2 adding an autoincrementing id column | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | In High Troughput Sequencing analysis we usually have many db tables with similar | ||
| 19 | structure and columns. DBIx::Class requires each Result class to specify the table name | ||
| 20 | explicitly. This means that we would have to explicitly create a Result class for | ||
| 21 | every db table. For this we created this class (does not specify a table name) which can | ||
| 22 | be inherited by other Result classes and provide a common table structure. | ||
| 23 | |||
| 24 | The class contains the basic common functionality for database tables that contain | ||
| 25 | sequenced reads. It offers accessor methods for table columns compatible with the | ||
| 26 | rest of the GenOO framework. | ||
| 27 | |||
| 28 | It consumes the GenOO::Region role. | ||
| 29 | |||
| 30 | As mentioned above this class should be used through inheritance. The reason for this | ||
| 31 | is that it does not have a specific database table on which it maps. The table used | ||
| 32 | within this class is defined as "Unknown" and should be specified by derived classes. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | # Let the code begin... | ||
| 37 | |||
| 38 | package GenOO::Data::DB::DBIC::Species::Schema::SampleResultBase::v3; | ||
| 39 | $GenOO::Data::DB::DBIC::Species::Schema::SampleResultBase::v3::VERSION = '1.5.0'; | ||
| 40 | |||
| 41 | ####################################################################### | ||
| 42 | ####################### Load External modules ##################### | ||
| 43 | ####################################################################### | ||
| 44 | use Modern::Perl; | ||
| 45 | use Moose; | ||
| 46 | use namespace::autoclean; | ||
| 47 | use MooseX::MarkAsMethods autoclean => 1; | ||
| 48 | |||
| 49 | |||
| 50 | ####################################################################### | ||
| 51 | ############################ Inheritance ########################## | ||
| 52 | ####################################################################### | ||
| 53 | extends 'DBIx::Class::Core'; | ||
| 54 | |||
| 55 | |||
| 56 | ####################################################################### | ||
| 57 | ####################### Interface attributes ###################### | ||
| 58 | ####################################################################### | ||
| 59 | # The interface attributes section provides Moose like accessors for | ||
| 60 | # the table columns. These methods basically overide those created by | ||
| 61 | # DBIx::Class. The column types are defined at the end of the class in | ||
| 62 | # the "Package Methods" section | ||
| 63 | |||
| 64 | has 'strand' => ( | ||
| 65 | is => 'rw', | ||
| 66 | ); | ||
| 67 | |||
| 68 | has 'rname' => ( | ||
| 69 | is => 'rw', | ||
| 70 | ); | ||
| 71 | |||
| 72 | has 'start' => ( | ||
| 73 | is => 'rw', | ||
| 74 | ); | ||
| 75 | |||
| 76 | has 'stop' => ( | ||
| 77 | is => 'rw', | ||
| 78 | ); | ||
| 79 | |||
| 80 | has 'copy_number' => ( | ||
| 81 | is => 'rw', | ||
| 82 | ); | ||
| 83 | |||
| 84 | has 'sequence' => ( | ||
| 85 | is => 'rw', | ||
| 86 | ); | ||
| 87 | |||
| 88 | has 'cigar' => ( | ||
| 89 | is => 'rw', | ||
| 90 | ); | ||
| 91 | |||
| 92 | has 'mdz' => ( | ||
| 93 | is => 'rw', | ||
| 94 | ); | ||
| 95 | |||
| 96 | has 'number_of_mappings' => ( | ||
| 97 | is => 'rw', | ||
| 98 | ); | ||
| 99 | |||
| 100 | has 'query_length' => ( | ||
| 101 | is => 'rw', | ||
| 102 | ); | ||
| 103 | |||
| 104 | has 'alignment_length' => ( | ||
| 105 | is => 'rw', | ||
| 106 | ); | ||
| 107 | |||
| 108 | has 'extra' => ( | ||
| 109 | is => 'rw' | ||
| 110 | ); | ||
| 111 | |||
| 112 | |||
| 113 | ####################################################################### | ||
| 114 | ########################## Consumed roles ######################### | ||
| 115 | ####################################################################### | ||
| 116 | with | ||
| 117 | 'GenOO::Region' => { | ||
| 118 | -alias => { mid_position => 'region_mid_position' }, | ||
| 119 | -excludes => 'mid_position', | ||
| 120 | }, | ||
| 121 | 'GenOO::Data::File::SAM::CigarAndMDZ' => { | ||
| 122 | }; | ||
| 123 | |||
| 124 | |||
| 125 | ####################################################################### | ||
| 126 | ######################## Interface Methods ######################## | ||
| 127 | ####################################################################### | ||
| 128 | sub sequence_length { | ||
| 129 | my ($self) = @_; | ||
| 130 | |||
| 131 | return $self->query_length if defined $self->query_length; | ||
| 132 | return CORE::length($self->sequence); | ||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | ####################################################################### | ||
| 137 | ######################### Package Methods ######################### | ||
| 138 | ####################################################################### | ||
| 139 | __PACKAGE__->table('Unknown'); | ||
| 140 | |||
| 141 | __PACKAGE__->add_columns( | ||
| 142 | 'id', { | ||
| 143 | data_type => 'integer', | ||
| 144 | extra => { unsigned => 1 }, | ||
| 145 | is_nullable => 0, | ||
| 146 | size => 9 | ||
| 147 | }, | ||
| 148 | 'strand', { | ||
| 149 | data_type => 'integer', | ||
| 150 | is_nullable => 0, | ||
| 151 | size => 1 | ||
| 152 | }, | ||
| 153 | 'rname', { | ||
| 154 | data_type => 'varchar', | ||
| 155 | is_nullable => 0, | ||
| 156 | size => 250 | ||
| 157 | }, | ||
| 158 | 'start', { | ||
| 159 | data_type => 'integer', | ||
| 160 | extra => { unsigned => 1 }, | ||
| 161 | is_nullable => 0 | ||
| 162 | }, | ||
| 163 | 'stop', { | ||
| 164 | data_type => 'integer', | ||
| 165 | extra => { unsigned => 1 }, | ||
| 166 | is_nullable => 0 | ||
| 167 | }, | ||
| 168 | 'copy_number', { | ||
| 169 | data_type => 'integer', | ||
| 170 | default_value => 1, | ||
| 171 | extra => { unsigned => 1 }, | ||
| 172 | is_nullable => 0, | ||
| 173 | }, | ||
| 174 | 'sequence', { | ||
| 175 | data_type => 'varchar', | ||
| 176 | is_nullable => 0, | ||
| 177 | size => 250 | ||
| 178 | }, | ||
| 179 | 'cigar', { | ||
| 180 | data_type => 'varchar', | ||
| 181 | is_nullable => 0, | ||
| 182 | size => 250 | ||
| 183 | }, | ||
| 184 | 'mdz', { | ||
| 185 | data_type => 'varchar', | ||
| 186 | is_nullable => 1, | ||
| 187 | size => 250 | ||
| 188 | }, | ||
| 189 | 'number_of_mappings', { | ||
| 190 | data_type => 'integer', | ||
| 191 | extra => { unsigned => 1 }, | ||
| 192 | is_nullable => 1 | ||
| 193 | }, | ||
| 194 | 'query_length', { | ||
| 195 | data_type => 'integer', | ||
| 196 | extra => { unsigned => 1 }, | ||
| 197 | is_nullable => 0 | ||
| 198 | }, | ||
| 199 | 'alignment_length', { | ||
| 200 | data_type => 'integer', | ||
| 201 | extra => { unsigned => 1 }, | ||
| 202 | is_nullable => 0 | ||
| 203 | }, | ||
| 204 | ); | ||
| 205 | |||
| 206 | __PACKAGE__->set_primary_key('id'); | ||
| 207 | ####################################################################### | ||
| 208 | ############################ Finalize ############################# | ||
| 209 | ####################################################################### | ||
| 210 | __PACKAGE__->meta->make_immutable(inline_constructor => 0); | ||
| 211 | |||
| 212 | 1; |