gnSourceSpec.cpp Source File

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