Esempio n. 1
0
MultiFormatReader * instantiateReader() {
    MultiFormatReader * nexusReader = new MultiFormatReader(-1, NxsReader::WARNINGS_TO_STDERR);
    if (gQuietMode) {
        nexusReader->SetWarningOutputLevel(NxsReader::SKIPPING_CONTENT_WARNING);
    }
    if (gStrictLevel != 2) {
        nexusReader->SetWarningToErrorThreshold((int)NxsReader::FATAL_WARNING + 1 - (int) gStrictLevel);
    }
    NxsCharactersBlock * charsB = nexusReader->GetCharactersBlockTemplate();
    NxsDataBlock * dataB = nexusReader->GetDataBlockTemplate();
    charsB->SetAllowAugmentingOfSequenceSymbols(true);
    dataB->SetAllowAugmentingOfSequenceSymbols(true);
    NxsTreesBlock * treesB = nexusReader->GetTreesBlockTemplate();
    assert(treesB);
    if (gStrictLevel < 2) {
        treesB->SetAllowImplicitNames(true);
    }
    treesB->setValidateInternalNodeLabels(gValidateInternals);
    treesB->setAllowNumericInterpretationOfTaxLabels(true);
    if (gStrictLevel < 2) {
        NxsStoreTokensBlockReader *storerB =  nexusReader->GetUnknownBlockTemplate();
        assert(storerB);
        storerB->SetTolerateEOFInBlock(true);
    }
    nexusReader->conversionOutputRecord.addNumbersToDisambiguateNames = true;
    return nexusReader;
}
Esempio n. 2
0
////////////////////////////////////////////////////////////////////////////////
// Creates a NxsReader, and tries to read the file `filename`.  If the
//	read succeeds, then processContent will be called.
////////////////////////////////////////////////////////////////////////////////
void processFilepath(
	const char * filename, // name of the file to be read
	ostream *out, // output stream to use (NULL for no output). Not that cerr is used to report errors.
	MultiFormatReader::DataFormatType fmt) // enum indicating the file format to expect.
	{
	assert(filename);
	try
		{
		MultiFormatReader nexusReader(-1, NxsReader::WARNINGS_TO_STDERR);
		if (gStrictLevel != 2)
			nexusReader.SetWarningToErrorThreshold((int)NxsReader::FATAL_WARNING + 1 - (int) gStrictLevel);
		NxsCharactersBlock * charsB = nexusReader.GetCharactersBlockTemplate();
		NxsDataBlock * dataB = nexusReader.GetDataBlockTemplate();
		charsB->SetAllowAugmentingOfSequenceSymbols(true);
		dataB->SetAllowAugmentingOfSequenceSymbols(true);
		if (gInterleaveLen > 0)
			{
			assert(charsB);
			charsB->SetWriteInterleaveLen(gInterleaveLen);
			dataB->SetWriteInterleaveLen(gInterleaveLen);
			}
		NxsTreesBlock * treesB = nexusReader.GetTreesBlockTemplate();
		assert(treesB);
		if (gStrictLevel < 2)
			treesB->SetAllowImplicitNames(true);
		if (!gTreesToSplitsB)
			gTreesToSplitsB = new TreesToSplits();
		treesB->setValidationCallbacks(newTreeHook, gTreesToSplitsB);
		if (gStrictLevel < 2)
			{
			NxsStoreTokensBlockReader *storerB =  nexusReader.GetUnknownBlockTemplate();
			assert(storerB);
			storerB->SetTolerateEOFInBlock(true);
			}
		cerr << "Executing" <<endl;
		try {
			nexusReader.ReadFilepath(filename, fmt);
			processContent(nexusReader, out);
			}
		catch(...)
			{
			nexusReader.DeleteBlocksFromFactories();
			throw;
			}
		nexusReader.DeleteBlocksFromFactories();
		}
	catch (const NxsException &x)
		{
		cerr << "Error:\n " << x.msg << endl;
		if (x.line >=0)
			cerr << "at line " << x.line << ", column (approximately) " << x.col << " (and file position "<< x.pos << ")" << endl;
		exit(2);
		}
	}
Esempio n. 3
0
MultiFormatReader * instantiateReader() {
  MultiFormatReader * nexusReader = new MultiFormatReader(-1, NxsReader::WARNINGS_TO_STDERR);
  if (gQuietMode)
    nexusReader->SetWarningOutputLevel(NxsReader::SKIPPING_CONTENT_WARNING);
  if (gStrictLevel != 2)
    nexusReader->SetWarningToErrorThreshold((int)NxsReader::FATAL_WARNING + 1 - (int) gStrictLevel);
  if (gUnderscoresToSpaces) 
    nexusReader->SetCoerceUnderscoresToSpaces(true);
  NxsCharactersBlock * charsB = nexusReader->GetCharactersBlockTemplate();
  NxsDataBlock * dataB = nexusReader->GetDataBlockTemplate();
  charsB->SetAllowAugmentingOfSequenceSymbols(true);
  dataB->SetAllowAugmentingOfSequenceSymbols(true);
  if (gInterleaveLen > 0) {
    assert(charsB);
    charsB->SetWriteInterleaveLen(gInterleaveLen);
    dataB->SetWriteInterleaveLen(gInterleaveLen);
  }
  
  NxsTreesBlock * treesB = nexusReader->GetTreesBlockTemplate();
  assert(treesB);
  if (gStrictLevel < 2)
    treesB->SetAllowImplicitNames(true);
  treesB->SetWriteFromNodeEdgeDataStructure(gTreesViaInMemoryStruct);
  treesB->setValidateInternalNodeLabels(gValidateInternals);
  if (gAltNexus)
    treesB->setWriteTranslateTable(false);
  if (gStrictLevel < 2) {
    NxsStoreTokensBlockReader *storerB =  nexusReader->GetUnknownBlockTemplate();
    assert(storerB);
    storerB->SetTolerateEOFInBlock(true);
  }
  nexusReader->conversionOutputRecord.addNumbersToDisambiguateNames = true;
  
  if (gSuppressingNameTranslationFile)
    nexusReader->conversionOutputRecord.writeNameTranslationFile = false;
  return nexusReader;
}