gnContigSpec.cpp Source File

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

# gnContigSpec.cpp

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnContigSpec.cpp
    00003 // Purpose:         Abstract Contig Spec class
    00004 // Description:     Defines an interface for contig specs
    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/gnContigSpec.h"
    00014 #include "gn/gnFilter.h"
    00015
    00016 void gnContigSpec::CropStart( gnSeqI cropLen ){
    00017         m_start = m_reverseComplement ? (GetSourceLength() + m_start - cropLen) % GetSourceLength() : (m_start + cropLen) % GetSourceLength();
    00018         m_length -= cropLen;
    00019         return;
    00020 }
    00021
    00022 void gnContigSpec::CropEnd( gnSeqI cropLen ){
    00023         m_length -= cropLen;
    00024 }
    00025
    00026 void gnContigSpec::SetReverseComplement( const boolean value )
    00027 {
    00028         //translate coordinates if revComp has changed.
    00029         if((m_reverseComplement != value) && (m_length > 0))
    00030                 m_start = (m_start + m_length) % GetSourceLength();
    00031         m_reverseComplement = value;
    00032 }
    00033
    00034 boolean gnContigSpec::SeqRead(const gnSeqI start, gnSeqC* buf, uint32& bufLen, const uint32 contigI ) const{
    00035         boolean success;
    00036         bufLen = bufLen < m_length - start? bufLen : m_length - start;  //trim the read down to size.
    00037         gnSeqI readable = bufLen;
    00038         gnSeqI read_start = start;      // coordinate translation
    00039
    00040         if(contigI == ALL_CONTIGS)
    00041                 read_start = m_reverseComplement ? (m_start - start - readable + GetSourceLength()) % GetSourceLength() : start + m_start;
    00042
    00043         success = Read(read_start, buf, readable);
    00044
    00045         if(m_circular){
    00046                 gnSeqI beginread = bufLen - readable;  //read whatever couldn't be read before
    00047                 read_start = m_reverseComplement ? (m_start - readable + GetSourceLength()) % GetSourceLength() : m_start;
    00048                 success = Read(read_start , buf + readable, beginread);
    00049                 readable += beginread;
    00050         }
    00051
    00052         bufLen = readable;
    00053
    00054         if(m_reverseComplement)
    00055                 gnFilter::DNAComplementFilter()->ReverseFilter(&buf, bufLen);
    00056
    00057         return success;
    00058 }
    00059
    00060 void gnContigSpec::Clear(){
    00061         gnBaseSpec::Clear();
    00062         m_start = 0;
    00063         m_length = 0;
    00064         m_SourceContigIndex = ALL_CONTIGS;
    00065 }