|
gnContigSpec.cppGo 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.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/gnContigSpec.h" 00015 #include "gn/gnFilter.h" 00016 00017 void gnContigSpec::CropStart( gnSeqI cropLen ){ 00018 m_start = m_reverseComplement ? (GetSourceLength() + m_start - cropLen) % GetSourceLength() : (m_start + cropLen) % GetSourceLength(); 00019 m_length -= cropLen; 00020 return; 00021 } 00022 00023 void gnContigSpec::CropEnd( gnSeqI cropLen ){ 00024 m_length -= cropLen; 00025 } 00026 00027 void gnContigSpec::SetReverseComplement( const boolean value ) 00028 { 00029 //translate coordinates if revComp has changed. 00030 if((m_reverseComplement != value) && (m_length > 0)) 00031 m_start = (m_start + m_length) % GetSourceLength(); 00032 m_reverseComplement = value; 00033 } 00034 00035 boolean gnContigSpec::SeqRead(const gnSeqI start, gnSeqC* buf, uint32& bufLen, const uint32 contigI ) const{ 00036 boolean success; 00037 bufLen = bufLen < m_length - start? bufLen : m_length - start; //trim the read down to size. 00038 gnSeqI readable = bufLen; 00039 gnSeqI read_start = start; // coordinate translation 00040 00041 if(contigI == ALL_CONTIGS) 00042 read_start = m_reverseComplement ? (m_start - start - readable + GetSourceLength()) % GetSourceLength() : start + m_start; 00043 00044 success = Read(read_start, buf, readable); 00045 00046 if(m_circular){ 00047 gnSeqI beginread = bufLen - readable; //read whatever couldn't be read before 00048 read_start = m_reverseComplement ? (m_start - readable + GetSourceLength()) % GetSourceLength() : m_start; 00049 success = Read(read_start , buf + readable, beginread); 00050 readable += beginread; 00051 } 00052 00053 bufLen = readable; 00054 00055 if(m_reverseComplement) 00056 gnFilter::DNAComplementFilter()->ReverseFilter(&buf, bufLen); 00057 00058 return success; 00059 } 00060 00061 void gnContigSpec::Clear(){ 00062 gnBaseSpec::Clear(); 00063 m_start = 0; 00064 m_length = 0; 00065 m_SourceContigIndex = ALL_CONTIGS; 00066 } Generated at Fri Nov 30 15:36:50 2001 for libGenome by 1.2.8.1 written by Dimitri van Heesch, © 1997-2001 |