/***************************************************************************** # 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. # #*****************************************************************************/ // // main.cpp // // main routine for consEd application // // // main.cpp_part1 // edit the following for new applications: main.cpp_part1, main.cpp_part11 // you can also edit main.cpp_part8 for compatibility between arguments #include #include #include #include #include #include #include #include "addAlignedSequence.h" #include "addNewReads.h" #include "addNewReadsAutomated.h" #include "addNewReadsWithExistingAlignments.h" #include "assemblyView.h" #include "autoEdit.h" #include "autoFinish.h" #include "autoPCRAmplify.h" #include "autoReport.h" #include "bIsNumericMaybeWithWhitespace.h" #include "checkLicenseKey.h" #include "checkVariableLengthLimit.h" #include "consed.h" #include "consedParameters.h" #include "consedResources.h" #include "consedResources.h" #include "consed_version.h" #include "contigwin.h" #include "fileDefines.h" #include "guiTopWindow.h" #include "guiapp.h" #include "listOfLibraries.h" #include "maybeTerminateIfAnotherReadWriteConsed.h" #include "mbt_exception.h" #include "perhapsCreateSocketToControlConsed.h" #include "printMemory.h" #include "printSingleSignal.h" #include "printTime.h" #include "readAndProcessReadPrefixFile.h" #include "rwctokenizer.h" #include "saveTagTypes.h" #include "setComplementBaseTable.h" #include "setErrorRateFromQuality.h" #include "setNotACGTTable.h" #include "setNumberFromBaseTable.h" #include "solexa2PhdBall.h" #include "sysdepend.h" #include "tagSNPs.h" #include "terminateIfNoPhdDir.h" #include "whatIsRunning.h" #include "phdBall2Fasta.h" #include "testReadPhdBall.h" #include "removeReads.h" #include "removeContigs.h" #include "printDefaultResources.h" #include "sff2PhdBall.h" #include "guiEditResourcesStandalone.h" #include "defaultResourcesDefinition.h" #include "batchChangeConsensus.h" #include "snpGenome.h" #include "diffChromosomes.h" #include "nextPhredPipeline.h" #include "fixContigEnds.h" #include "geneClassifications.h" #include "phaster2PhdBall.h" #include "miscProgram.h" // definition for soEmptyString.h RWCString soEmptyString = ""; bool bNoBaseSeg = false; bool bNoSetSequence = false; bool bNoFragments = false; bool bNoListOfFragments = false; bool bUnsortedBaseSegArray = false; bool bUsingPhdFiles = true; bool bReadOnly = false; int nNumberOfErrorWindowsCurrentlyUp = 0; // global, used by // popupInfoOrErrorMessageNoFormat.cpp jmp_buf jmpBuffer; const int nErrorReturn = 1; static void handleSegmentationFault( int nSigNo ) { fprintf( stderr, "Error from consed: segmentation fault. Attempting to continue\n" ); longjmp( jmpBuffer, nErrorReturn ); } static bool bEstablishErrorHandler() { if ( setjmp( jmpBuffer ) == nErrorReturn ) { // just returned from an error if ( setjmp( jmpBuffer ) != 0 ) { cerr << "can't establish setjmp for handler of segmentation faults" << endl; } } else if ( setjmp( jmpBuffer ) == 0 ) { if ( signal( SIGSEGV, handleSegmentationFault ) == SIG_ERR ) { cerr << "can't establish handler for segmentation faults" << endl; } return( true ); } else { cerr << "can't establish setjmp for handler of segmentation faults2" << endl; } return( false ); } static void myNewHandler() { printMemory( "In new memory handler" ); cerr<< "Consed: out of memory on heap (datasize)" << endl; cerr<< "new threw an exception--you have run out of memory" << endl; cerr<< "There is not enough datasize (heap)." << endl; cerr<< "There may not be enough physical memory, or else" << endl; cerr<< "there may be a software limit imposed on this process." << endl; cerr<< "With tcsh, use type: limit to see what you are currently using." << endl; cerr<< "Then type: limit datasize unlimited " << endl << ends; cerr.flush(); ostrstream ost; ost << "Consed: out of memory on heap (datasize)" << endl; ost << "new threw an exception--you have run out of memory" << endl; ost << "There is not enough datasize (heap)." << endl; ost << "There may not be enough physical memory, or else" << endl; ost << "there may be a software limit imposed on this process." << endl; ost << "With tcsh, use type: limit to see what you are currently using." << endl; ost << "Then type: limit datasize unlimited " << endl << ends; SysRequestFailed sys( ost.str() ); throw( sys ); } static void checkIfOperatingSystemIsOK() { struct utsname myUtsname; int nError = uname( &myUtsname ); if ( nError != -1 ) { RWCString soOperatingSystem; soOperatingSystem.getField( myUtsname.sysname, 9 ); soOperatingSystem.toLower(); if ( soOperatingSystem == "linux" ) { RWCString soRelease; soRelease.getField( myUtsname.release, 9 ); RWCString soVersion; soVersion.getField( myUtsname.version, 9 ); // cerr << "release: " << soRelease << " version: " << soVersion << endl; // check that this is 2.4 or better // current version is 2.4.2-2sm // Algorithm: look for the first character that isn't // a [0-9] or "." and just consider that portion. Separate it // by "." If the first number is greater than 3, accept. Otherwise // it must be a 2 and look at the next number. If the next // number is more than a 4, accept, otherwise it must be a 4 and // look at the next number. The next number must be a 2 or greater // in this case. size_t nFirstBad = strspn( soRelease.data(), "0123456789." ); soRelease.truncate( nFirstBad ); RWCTokenizer tok( soRelease ); RWCString soFirst = tok('.'); RWCString soSecond = tok('.'); RWCString soThird = tok('.' ); int nFirst; assert( bIsNumericMaybeWithWhitespace( soFirst, nFirst ) ); if ( nFirst > 2 ) return; // we are fine. if ( nFirst < 2 ) { cerr << "Sorry: the linux kernel must be version 2.4.2 or better. Type \"uname -a\" to find your current version. (1)" << endl; exit( -1 ); } // if reached here, must be version 2.?.? int nSecond; assert( bIsNumericMaybeWithWhitespace( soSecond, nSecond ) ); if ( nSecond > 4 ) return; // we are fine if ( nSecond < 4 ) { cerr << "Sorry: the linux kernel must be version 2.4.2 or better. Type \"uname -a\" to find your current version. (2)" << endl; exit( -1 ); } int nThird; assert( bIsNumericMaybeWithWhitespace( soThird, nThird ) ); if ( nThird >= 2 ) return; // we are fine // if reached here, the user is using an operating system that is // too old. cerr << "Sorry: the linux kernel must be version 2.4.2 or better. Type \"uname -a\" to find your current version. (3)" << endl; exit( -1 ); } else if ( soOperatingSystem == "darwin" ) { RWCString soRelease; soRelease.getField( myUtsname.release, 9 ); cerr << "Darwin Version: " << soRelease << endl; size_t nFirstBad = strspn( soRelease.data(), "0123456789." ); soRelease.truncate( nFirstBad ); RWCTokenizer tok( soRelease ); RWCString soFirst = tok('.'); RWCString soSecond = tok('.'); RWCString soThird = tok('.' ); int nVersion; if (!bIsNumericMaybeWithWhitespace( soFirst, nVersion ) ) { return; // don't know if we are ok, but don't know we are not ok } if ( nVersion < 6 ) { cerr << "Sorry: if you are running Macosx, you must be running version 10.2 or better (Darwin kernel 6.0 or better)" << endl; exit( -1 ); } } } }