gnStringSpec.cpp Source File

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

# gnStringSpec.cpp

Go to the documentation of this file.

    00001
    00002 // File:            gnStringSpec.cpp
    00003 // Purpose:         implements gnContigSpec for strings
    00004 // Description:     stores sequence in memory
    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/gnStringSpec.h"
    00015 #include <string>
    00016
    00017 gnStringSpec::gnStringSpec()
    00018 {
    00019         Clear();
    00020 }
    00021
    00022 gnStringSpec::gnStringSpec( const string& m_string, gnSeqI start, gnSeqI endI, boolean revComp)
    00023 {
    00024         m_seqString = m_string;
    00025         m_start = start;
    00026         gnSeqI actual_len = m_seqString.length();
    00027
    00028         //reverse comp has the end b.p. first, then start.  switch them.
    00029         m_start = revComp ? endI : start;
    00030         gnSeqI actual_end = revComp ? start : endI;
    00031         //trim start and end down if they are too big.
    00032         actual_end = actual_end < actual_len ? actual_end : actual_len -1;
    00033         m_start = m_start < actual_len ? m_start : actual_len - 1;
    00034         if(actual_len == 0)
    00035                 m_start = 0;
    00036         //if start is after end, we're using a circular sequence.
    00037         m_circular = m_start > actual_end ? true : false;
    00038         //if circular, the length will be different.
    00039         m_length = m_circular ? (actual_len - m_start) + actual_end : actual_end - m_start + 1;
    00040
    00041         m_reverseComplement = revComp;
    00042         m_SourceContigIndex = ALL_CONTIGS;
    00043 }
    00044
    00045 gnStringSpec::gnStringSpec( const gnStringSpec& s )
    00046 {
    00047         m_seqString = s.m_seqString;
    00048         m_sourceName = s.m_sourceName;
    00049         m_name = s.m_name;
    00050         m_start = s.m_start;
    00051         m_length = s.m_length;
    00052         m_reverseComplement = s.m_reverseComplement;
    00053         m_circular = s.m_circular;
    00054         m_SourceContigIndex = s.m_SourceContigIndex;
    00055 }
    00056 gnStringSpec::~gnStringSpec()
    00057 {
    00058         Clear();
    00059 }
    00060 void gnStringSpec::Clear()
    00061 {
    00062         gnContigSpec::Clear();
    00063         m_seqString = "";
    00064 }
    00065
    00066 gnStringSpec* gnStringSpec::CloneRange( const gnSeqI startI, const gnSeqI len ) const{
    00067         gnStringSpec* destSpec = new gnStringSpec();
    00068         destSpec->m_seqString = m_seqString.substr(m_start + startI, len);
    00069         destSpec->m_sourceName = m_sourceName;
    00070         destSpec->m_name = m_name;
    00071         destSpec->m_start = 0;
    00072         destSpec->m_length = destSpec->m_seqString.length();
    00073         destSpec->m_reverseComplement = m_reverseComplement;
    00074         destSpec->m_circular = m_circular;
    00075         destSpec->m_SourceContigIndex = m_SourceContigIndex;
    00076         return destSpec;
    00077 }