See More

// ========================================================================== // lambda // ========================================================================== // Copyright (c) 2013-2017, Hannes Hauswedell

// Copyright (c) 2016-2017, Knut Reinert and Freie Universität Berlin // All rights reserved. // // This file is part of Lambda. // // Lambda is Free Software: you can redistribute it and/or modify it // under the terms found in the LICENSE[.md|.rst] file distributed // together with this file. // // Lambda is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // // ========================================================================== // lambda.cpp: Main File for the main application // ========================================================================== #include #include #include #include #define LAMBDA_INDEXER 1 // some things are different for the indexer binary #include "lambda_indexer.hpp" using namespace seqan; // ========================================================================== // Forwards // ========================================================================== inline int argConv0(LambdaIndexerOptions const & options); template inline int argConv1(LambdaIndexerOptions const & options, BlastProgramSelector

const &); template inline int argConv2(LambdaIndexerOptions const & options, BlastProgramSelector

const &, TRedAlph const &); template inline int realMain(LambdaIndexerOptions const & options, BlastProgramSelector

const &, TRedAlph const &, TIndexSpecSpec const &); // ========================================================================== // Functions // ========================================================================== // -------------------------------------------------------------------------- // Function main() // -------------------------------------------------------------------------- // Program entry point. int main(int argc, char const ** argv) { // Parse the command line. seqan::ArgumentParser parser; LambdaIndexerOptions options; seqan::ArgumentParser::ParseResult res = parseCommandLine(options, argc, argv); // If there was an error parsing or built-in argument parser functionality // was triggered then we exit the program. The return code is 1 if there // were errors and 0 if there were none. if (res != seqan::ArgumentParser::PARSE_OK) return res == seqan::ArgumentParser::PARSE_ERROR; if (std::string(CMAKE_BUILD_TYPE) != "Release") std::cerr << "WARNING: This binary is not built in release mode and will be much slower than it should be!\n"; return argConv0(options); } inline int argConv0(LambdaIndexerOptions const & options) { switch(options.blastProgram) { case BlastProgram::BLASTN: return argConv1(options, BlastProgramSelector<:blastn>()); case BlastProgram::BLASTP: return argConv1(options, BlastProgramSelector<:blastp>()); case BlastProgram::BLASTX: return argConv1(options, BlastProgramSelector<:blastx>()); case BlastProgram::TBLASTN: return argConv1(options, BlastProgramSelector<:tblastn>()); case BlastProgram::TBLASTX: return argConv1(options, BlastProgramSelector<:tblastx>()); default: break; } return -1; } /// Alphabet reduction template inline int argConv1(LambdaIndexerOptions const & options, BlastProgramSelector

const &) { using TUnred = typename std::conditional

::type; using Tp = BlastProgramSelector

; switch (options.alphReduction) { case 0: return argConv2(options, Tp(), TUnred()); case 2: return argConv2(options, Tp(), ReducedAminoAcid()); #if 0 case 10: return argConv2(options, ReducedAminoAcid>()); case 1: return argConv2(options, AminoAcid10()); case 8: return argConv2(options, ReducedAminoAcid>()); case 12: return argConv2(options, ReducedAminoAcid>()); #endif default: return -1; } return -1; } template inline int argConv2(LambdaIndexerOptions const & options, BlastProgramSelector

const &, TRedAlph const &) { if (options.algo == "radixsort") return realMain(options, BlastProgramSelector

(), TRedAlph(), RadixSortSACreateTag()); else return realMain(options, BlastProgramSelector

(), TRedAlph(), Nothing()); } template inline int realMain(LambdaIndexerOptions const & options, BlastProgramSelector

const &, TRedAlph const &, TIndexSpecSpec const &) { using TOrigSet = TCDStringSet>>; using TTransSet = TCDStringSet>>; TTransSet translatedSeqs; { TOrigSet originalSeqs; int ret = 0; // ids get saved to disk again immediately and are not kept in memory ret = loadSubjSeqsAndIds(originalSeqs, options); if (ret) return ret; // preserve lengths of untranslated sequences if (sIsTranslated(p)) _saveOriginalSeqLengths(originalSeqs.limits, options); // convert the seg file to seqan binary format ret = convertMaskingFile(length(originalSeqs), options); if (ret) return ret; // translate or swap depending on program translateOrSwap(translatedSeqs, originalSeqs, options); } // dump translated and unreduced sequences (except where they are included in index) if ((options.alphReduction != 0) || (options.dbIndexType != 0)) dumpTranslatedSeqs(translatedSeqs, options); // see if final sequence set actually fits into index if (!checkIndexSize(translatedSeqs)) return -1; if (options.dbIndexType == 1) { using TIndexSpec = TFMIndex; generateIndexAndDump(translatedSeqs, options, BlastProgramSelector

(), TRedAlph()); } else { using TIndexSpec = IndexSa; generateIndexAndDump(translatedSeqs, options, BlastProgramSelector

(), TRedAlph()); } return 0; }