/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ #include "contigEndPair.h" #include "contig.h" #include "contigEnd.h" #include "rwcstring.h" contigEndPair :: contigEndPair( Contig* pContig0, Contig* pContig1, const int nWhichEnd0, const int nWhichEnd1 ) : pChoiceOfTemplatesForMinilibraries_( NULL ), pArrayOfTemplates_( NULL ), bInconsistent_( false ), bAlreadySuggestedMinilibrariesForThisGap_( false ), bUserDefined_( false ), bGapSizeSet_( false ), nGapSize_( 0 ), nHighQualityGapSize_( 0 ), nNumberOfForwardReversePairs_( 0 ) { if ( pContig0->soGetName() < pContig1->soGetName() ) { pContig_[0] = pContig0; pContig_[1] = pContig1; nWhichEnd_[0] = nWhichEnd0; nWhichEnd_[1] = nWhichEnd1; } else { pContig_[0] = pContig1; pContig_[1] = pContig0; nWhichEnd_[0] = nWhichEnd1; nWhichEnd_[1] = nWhichEnd0; } pTag_[0] = NULL; pTag_[1] = NULL; } void contigEndPair :: recordTags( tag* pTag0, tag* pTag1 ) { if ( pTag0->pContig_->soGetName() < pTag1->pContig_->soGetName() ) { pTag_[0] = pTag0; pTag_[1] = pTag1; } else { pTag_[0] = pTag1; pTag_[1] = pTag0; } } RWCString contigEndPair :: soGetDescription() { RWCString soDescription( (size_t) 300 ); for( int nEnd = 0; nEnd <= 1; ++nEnd ) { soDescription += pContig_[nEnd]->soGetName(); soDescription += " "; soDescription += szWhichGap( nWhichEnd_[ nEnd ] ); if ( nEnd == 0 ) { soDescription += " to "; } } // now put it in the format A-B or Ac-B or A-Bc soDescription += " ("; if ( nWhichEnd_[0] != nWhichEnd_[1] ) { // case in which neither contig needs to be complemented if ( nWhichEnd_[0] == nLeftGap ) { // so want 1-0 soDescription += pContig_[1]->soGetAbbreviatedName(); soDescription += "-"; soDescription += pContig_[0]->soGetAbbreviatedName(); } else { soDescription += pContig_[0]->soGetAbbreviatedName(); soDescription += "-"; soDescription += pContig_[1]->soGetAbbreviatedName(); } } else { // case in which one of the contigs must be complemented int nIndexOfLargerContig = ( pContig_[0]->nGetPaddedConsLength() > pContig_[1]->nGetPaddedConsLength() ? 0 : 1 ); int nIndexOfSmallerContig = ( nIndexOfLargerContig == 0 ? 1 : 0 ); if ( nWhichEnd_[0] == nLeftGap ) { // there are two possibilities: 1c-0 or 0c-1 // let's choose between them based on which contig is larger soDescription += pContig_[nIndexOfSmallerContig]->soGetAbbreviatedName(); soDescription += "c-"; soDescription += pContig_[nIndexOfLargerContig]->soGetAbbreviatedName(); } else { // there are two possibilities 0-1c or 1-0c // let's choose between them based on which contig is larger soDescription += pContig_[nIndexOfLargerContig]->soGetAbbreviatedName(); soDescription += "-"; soDescription += pContig_[nIndexOfSmallerContig]->soGetAbbreviatedName(); soDescription += "c"; } } soDescription += ")"; return( soDescription ); } void contigEndPair :: calculateHighQualityGapSize() { // this assumes that nGapSize_ is already set nHighQualityGapSize_ = nGapSize_; for( int nContigEnd = 0; nContigEnd <= 1; ++nContigEnd ) { Contig* pContig = pContig_[ nContigEnd ]; int nWhichEnd = nWhichEnd_[ nContigEnd ]; int nLowQualityBases = pContig->nGetUnpaddedClippedLowQualityBases( nWhichEnd ); nHighQualityGapSize_ += nLowQualityBases; } assert( nHighQualityGapSize_ >= nGapSize_ ); } void contigEndPair :: makeAllTemplatesConsistent() { if ( pArrayOfTemplates_ ) { for( int nSub = 0; nSub < pArrayOfTemplates_->length(); ++nSub ) { subcloneTTemplate* pSub = (*pArrayOfTemplates_)[ nSub ]; pSub->bInconsistentGapSpanning_ = false; pSub->determineIfOKToUseTemplate(); } } }