libMems/GappedAligner.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * $Id: GappedAligner.h,v 1.12 2004/04/19 23:10:50 darling Exp $
00003  * This file is copyright 2002-2007 Aaron Darling and authors listed in the AUTHORS file.
00004  * This file is licensed under the GPL.
00005  * Please see the file called COPYING for licensing details.
00006  * **************
00007  ******************************************************************************/
00008 
00009 #ifndef _GappedAligner_h_
00010 #define _GappedAligner_h_
00011 
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #endif
00015 
00016 #include "libGenome/gnSequence.h"
00017 #include "libMems/GappedAlignment.h"
00018 #include "libMems/Match.h"
00019 
00020 namespace mems {
00021 
00022 class GappedAligner {
00023 public:
00024         GappedAligner(){ max_alignment_length = 10000; }        // default to something
00025         GappedAligner& operator=( const GappedAligner& ga )
00026         { 
00027                 max_alignment_length = ga.max_alignment_length;
00028                 return *this;
00029         }
00035         void SetMaxAlignmentLength( gnSeqI len ){max_alignment_length = len;}
00036         virtual boolean Align( GappedAlignment& cr, Match* r_begin, Match* r_end, std::vector< genome::gnSequence* >& seq_table ) = 0;
00037 protected:
00038         gnSeqI max_alignment_length;
00039 };
00040 
00041 
00042 
00043 
00044 
00045 boolean getInterveningCoordinates( std::vector< genome::gnSequence* >& seq_table, Match* r_begin, Match* r_end, uint seqI, int64& gap_lend, int64& gap_rend );
00046 
00047 inline
00048 boolean getInterveningCoordinates( std::vector< genome::gnSequence* >& seq_table, Match* r_begin, Match* r_end, uint seqI, int64& gap_lend, int64& gap_rend ){
00049         // skip this sequence if it's undefined
00050         if( (r_end != NULL && r_end->Start( seqI ) == NO_MATCH) ||
00051                 (r_begin != NULL && r_begin->Start( seqI ) == NO_MATCH) ){
00052                 gap_lend = 0;
00053                 gap_rend = 0;
00054                 return true;
00055         }
00056                         
00057         // determine the size of the gap
00058         gap_rend = r_end != NULL ? r_end->Start( seqI ) : seq_table[ seqI ]->length() + 1;
00059         gap_lend = r_begin != NULL ? r_begin->End( seqI ) + 1 : 1;
00060         if( gap_rend < 0 || gap_lend < 0 ){
00061                 gap_rend = r_begin != NULL ? -r_begin->Start( seqI ) : seq_table[ seqI ]->length() + 1;
00062                 gap_lend = r_end != NULL ? -r_end->Start( seqI ) + r_end->Length() : 1;
00063         }
00064         if( gap_rend <= 0 || gap_lend <= 0 ){
00065                 // if either is still < 0 then there's a problem...
00066                 genome::ErrorMsg( "Error constructing intervening coordinates" );
00067         }
00068         return true;
00069 }
00070 
00071 }
00072 
00073 #endif // _GappedAligner_h_

Generated on Fri Mar 14 06:01:02 2008 for libMems by doxygen 1.3.6