/***************************************************************************** # 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. # #*****************************************************************************/ postProcessing(); } // consedParameters() void consedParameters :: processDoNotFinishTagTypes() { aAutoFinishTagsToNotFinish_.clear(); RWCTokenizer tokTagTypes( soAutoFinishDoNotFinishWhereTheseTagsAre_ ); RWCString soDoNotFinishTag; while( !( soDoNotFinishTag = tokTagTypes() ).isNull() ) { if ( !tagTypes::pGetTagTypes()->bIsAValidTagType( soDoNotFinishTag ) ) { ostrstream ost; ost << "You specified consed.autoFinishDoNotFinishWhereTheseTagsAre: " << soAutoFinishDoNotFinishWhereTheseTagsAre_ << " but \"" << soDoNotFinishTag << "\" is not a recognized tag type." << ends; InputDataError ide(ost.str()); throw ide; } aAutoFinishTagsToNotFinish_.insert( soDoNotFinishTag ); } } void consedParameters :: processDoNotExtendTagTypes() { aAutoFinishTagsToNotExtend_.clear(); RWCTokenizer tokTagTypes( soAutoFinishDoNotExtendContigsWhereTheseTagsAre_ ); RWCString soDoNotExtendTag; while( !( soDoNotExtendTag = tokTagTypes() ).isNull() ) { if ( !tagTypes::pGetTagTypes()->bIsAValidTagType( soDoNotExtendTag ) ) { RWCString soError = "You specified consed.autoFinishDoNotExtendContigsWhereTheseTagsAre: "; soError += soAutoFinishDoNotExtendContigsWhereTheseTagsAre_; soError += " but \""; soError += soDoNotExtendTag; soError += "\" is not a recognized tag type."; THROW_ERROR( soError ); } aAutoFinishTagsToNotExtend_.insert( soDoNotExtendTag ); } } // this is useful for setting parameters that depend on other parameters void consedParameters :: postProcessing() { // dAutoFinishMinNumberOfErrorsFixedByAnExpToUse_ = // dAutoFinishMinNumberOfErrorsFixedByAnExp_ / // (double) dAutoFinishRedundancy_; dAutoFinishMinNumberOfErrorsFixedByAnExpToUse_ = dAutoFinishMinNumberOfErrorsFixedByAnExp_; RWCTokenizer tok( soUserDefinedKeys_ ); RWCString soWord; while( !( soWord = tok() ).isNull() ) { int nKey; if ( !bIsNumericMaybeWithWhitespace( soWord, nKey ) ) { PANIC_OST( ost ) << "resource consed.userDefinedKeys should contain just integers which are the values of keysyms of keys defined in /usr/include/X11/keysymdefs.h, but instead it contains " << soUserDefinedKeys_ << ends; InputDataError ide( ost.str() ); throw ide; } aUserDefinedKeys_.insert( nKey ); } RWCTokenizer tok2( soProgramsForUserDefinedKeys_ ); while( !( soWord = tok2() ).isNull() ) { aProgramsForUserDefinedKeys_.insert( soWord ); } RWCTokenizer tok3( soArgumentsToPassToUserDefinedPrograms_ ); while( !( soWord = tok3() ).isNull() ) { aArgumentsToPassToUserDefinedPrograms_.insert( soWord ); } RWCTokenizer tok4( soTagsToApplyWithUserDefinedKeys_ ); while( !( soWord = tok4() ).isNull() ) { aTagsToApplyWithUserDefinedKeys_.insert( soWord ); } if ( ! ( aUserDefinedKeys_.length() == aProgramsForUserDefinedKeys_.length() && aProgramsForUserDefinedKeys_.length() == aArgumentsToPassToUserDefinedPrograms_.length() && aArgumentsToPassToUserDefinedPrograms_.length() == aTagsToApplyWithUserDefinedKeys_.length() ) ) { PANIC_OST( ost ) << "resource consed.userDefinedKeys has # of keys: " << aUserDefinedKeys_.length() << " with value " << soUserDefinedKeys_ << " resource consed.programsForUserDefinedKeys has # of entries: " << aProgramsForUserDefinedKeys_.length() << " with value " << soProgramsForUserDefinedKeys_ << " resource consed.argumentsToPassToUserDefinedPrograms " << " has # of entries: " << aArgumentsToPassToUserDefinedPrograms_.length() << " with value " << soArgumentsToPassToUserDefinedPrograms_ << " but these should all have the same number of entries" << ends; InputDataError ide( ost.str() ); throw ide; } readFileToOrderReadsInAlignedReadsWindow(); // parse: // pCP->soAutoReportPrintDiscrepantRegionsButIgnoreReadsContainingThis_ // to load // pCP->aAutoReportPatternsOfReadsToIgnore_ RWCTokenizer tokReadsToIgnore( soAutoReportPrintDiscrepantRegionsButIgnoreReadsContainingThis_ ); RWCString soReadPatternToIgnore; while( !( soReadPatternToIgnore = tokReadsToIgnore() ).isNull() ) { aAutoReportPatternsOfReadsToIgnore_.insert( soReadPatternToIgnore ); } if ( soSolexa64FastqOrSanger33Fastq_ != "auto" && soSolexa64FastqOrSanger33Fastq_ != "solexa64" && soSolexa64FastqOrSanger33Fastq_ != "sanger33" ) { RWCString soError = "consed.solexa64FastqOrSanger33Fastq: should be one of auto, solexa64, or sanger33 but is " + soSolexa64FastqOrSanger33Fastq_; THROW_ERROR( soError ); } } void consedParameters :: postProcessingAfterTagTypes() { // add resource soAssemblyViewDisplayTheseTagTypesOnTheseLines_ // into pCP->aAssemblyViewDisplayTheseTagTypesOnTheseLines_ and sort it so ready // for binary search. #define ADD_ASSEMBLY_VIEW_LINE_TO_ERROR_MESSAGE \ soError += " in line: \nconsed.assemblyViewDisplayTheseTagTypesOnTheseLines: "; \ soError += soAssemblyViewDisplayTheseTagTypesOnTheseLines_; RWCTokenizer tokAssemblyViewDisplayTheseTagTypesOnTheseLines( soAssemblyViewDisplayTheseTagTypesOnTheseLines_ ); RWCString soTagType; while( !( soTagType = tokAssemblyViewDisplayTheseTagTypesOnTheseLines() ).isNull() ) { // is this really a tag type, or did the user make a typo? if ( ! tagTypes::pGetTagTypes()->bIsAValidTagType( soTagType ) ) { RWCString soError = "Warning: "; soError += soTagType; soError += " is not a valid tag type "; ADD_ASSEMBLY_VIEW_LINE_TO_ERROR_MESSAGE; // I think I will not make this error fatal. The users // can deal with it later (or not at all). cerr << soError << endl; break; } RWCString soLine = tokAssemblyViewDisplayTheseTagTypesOnTheseLines(); if ( soLine.isNull() ) { RWCString soError = "Warning: There must be a pair of tagType and line number but "; soError += soTagType; soError += " does not have an associated line number "; ADD_ASSEMBLY_VIEW_LINE_TO_ERROR_MESSAGE; cerr << soError << endl; break; } int nLine; if ( !bIsNumericMaybeWithWhitespace( soLine, nLine ) ) { RWCString soError = "Warning: "; soError += soLine; soError += " is not numeric but should be "; ADD_ASSEMBLY_VIEW_LINE_TO_ERROR_MESSAGE; cerr << soError << endl; break; } if ( nLine < 0 || nLine > nAssemblyViewDisplayTagMaxLineIndex ) { RWCString soError = "Warning: "; soError += soLine; soError += " is out of bounds. Should be between "; soError += RWCString( (long) 0 ); soError += " and "; soError += RWCString( (long) nAssemblyViewDisplayTagMaxLineIndex ); ADD_ASSEMBLY_VIEW_LINE_TO_ERROR_MESSAGE; cerr << soError << endl; break; } aAssemblyViewDisplayTheseTagTypes_.insert( new assemblyViewTagTypeAndLine( soTagType, nLine ) ); } aAssemblyViewDisplayTheseTagTypes_.resort(); } void consedParameters :: readFileToOrderReadsInAlignedReadsWindow() { aShowReadsInAlignedReadsWindowOrderGivenByFile_.clearAndDestroy(); FILE* pFileToOrderReads = fopen( filShowReadsInAlignedReadsWindowOrderedByThisFile_.data(), "r" ); if ( !pFileToOrderReads ) { fprintf( stderr, "couldn't open %s--that's ok\n", filShowReadsInAlignedReadsWindowOrderedByThisFile_.data() ); return; } while( fgets( soLine.sz_, nMaxLineSize, pFileToOrderReads ) != NULL ) { soLine.nCurrentLength_ = strlen( soLine.sz_ ); soLine.stripTrailingWhitespaceFast(); if ( soLine.isNull() ) continue; // convert * to the regexp expression .* for( int n = (int) soLine.length() - 1; n >= 0; --n ) { if ( soLine[n] == '*' ) { soLine.insert( n, "." ); } } // put ^ and $ around the string to make it completely // match the read name soLine.insert( 0, "^" ); soLine.append( "$" ); RWCRegexp* pRegExp = new RWCRegexp( soLine ); aShowReadsInAlignedReadsWindowOrderGivenByFile_.insert( pRegExp ); } fclose( pFileToOrderReads ); }