00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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;
00046
00047
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
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 }