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