Google

Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

gnSourceSpec.cpp

Go to the documentation of this file.
00001 
00002 // File:            gnSourceSpec.cpp
00003 // Purpose:         implements gnContigSpec for source specs
00004 // Description:     
00005 // Changes:        
00006 // Version:         libGenome 0.1.0 
00007 // Author:          Aaron Darling 
00008 // Last Edited:     April 15, 2001, 11:13:00pm 
00009 // Modified by:     
00010 // Copyright:       (c) Aaron Darling 
00011 // Licenses:        Proprietary 
00013 
00014 #include "gn/gnSourceSpec.h"
00015 
00016 gnSourceSpec::gnSourceSpec()
00017 {
00018         Clear();
00019 }
00020 
00021 gnSourceSpec::gnSourceSpec( const gnSourceSpec& s )
00022 {
00023         m_pSource = s.m_pSource;
00024         m_sourceName = string(s.m_sourceName);
00025         m_name = string(s.m_name);
00026         m_SourceContigIndex = s.m_SourceContigIndex;
00027         m_start = s.m_start;
00028         m_length = s.m_length;
00029         m_reverseComplement = s.m_reverseComplement;
00030         m_circular = s.m_circular;
00031 }
00032 
00033 gnSourceSpec::gnSourceSpec( gnBaseSource* source, const uint32 m_ContigIndex, const gnSeqI start, const gnSeqI endI, const boolean revComp)
00034 {
00035         m_pSource = source;
00036         m_SourceContigIndex = m_ContigIndex;
00037         m_name = "";
00038         m_reverseComplement = revComp;
00039         m_circular = false;
00040         m_start = start;
00041         
00042         gnSeqI actual_len = source->GetContigSeqLength(m_ContigIndex);
00043         gnSeqI actual_end = endI;
00044         if(actual_len == 0)     
00045                 return; //this is a bogus gnSourceSpec
00046 
00047         //trim start and end down if they are too big.
00048         m_start = m_start < actual_len ? m_start : actual_len - 1;
00049         actual_end = actual_end < actual_len ? actual_end : actual_len - 1;
00050         //set the circularity and length
00051         if(revComp){
00052                 m_circular = m_start < actual_end ? true : false;
00053                 m_length = ((m_start - actual_end + actual_len) % actual_len);
00054         }else{
00055                 m_circular = m_start > actual_end ? true : false;
00056                 m_length = ((actual_end - m_start + actual_len) % actual_len);
00057         }
00058         if(actual_len != 0)
00059                 m_length++;
00060 
00061 }
00062 
00063 gnSourceSpec::~gnSourceSpec()
00064 {
00065 }
00066 
00067 void gnSourceSpec::Clear()
00068 {
00069         gnContigSpec::Clear();
00070         m_SourceContigIndex = 0;
00071         m_pSource = NULL;
00072 }
00073 
00074 gnSourceSpec* gnSourceSpec::CloneRange( const gnSeqI startI, const gnSeqI len ) const{
00075         gnSourceSpec* destSpec = new gnSourceSpec();
00076         destSpec->m_pSource = m_pSource;
00077         destSpec->m_sourceName = m_sourceName;
00078         destSpec->m_name = m_name;
00079         destSpec->m_SourceContigIndex = m_SourceContigIndex;
00080         destSpec->m_start = m_start + startI;
00081         destSpec->m_length = len < m_length - startI ? len : m_length - startI;
00082         destSpec->m_reverseComplement = m_reverseComplement;
00083         destSpec->m_circular = m_circular;
00084         return destSpec;
00085 }

Generated at Fri Nov 30 15:36:52 2001 for libGenome by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001