Exemplo n.º 1
0
CScope& CAlnMrgApp::GetScope(void) const
{
    if (!m_Scope) {
        m_ObjMgr = CObjectManager::GetInstance();
        CGBDataLoader::RegisterInObjectManager(*m_ObjMgr);
        
        m_Scope = new CScope(*m_ObjMgr);
        m_Scope->AddDefaults();
    }
    return *m_Scope;
}
Exemplo n.º 2
0
CScope& GetScope(void)
{
    static CRef<CScope> s_Scope;
    if ( !s_Scope ) {
        CRef<CObjectManager> objmgr = CObjectManager::GetInstance();
        CGBDataLoader::RegisterInObjectManager(*objmgr);
        
        s_Scope.Reset(new CScope(*objmgr));
        s_Scope->AddDefaults();
    }
    return *s_Scope;
}
Exemplo n.º 3
0
int ReadFastaQueries(const string& filename,
                      vector< CRef<objects::CSeq_loc> >& seqs,
                      CRef<objects::CScope>& scope,
                      bool parse_deflines /* = false*/,
                      objects::CSeqIdGenerator* id_generator /* = NULL*/)
{
    seqs.clear();
    CNcbiIfstream instream(filename.c_str());
    if (!instream) {
        return -1;
    }

    CStreamLineReader line_reader(instream);
    CFastaReader::TFlags flags =  CFastaReader::fAssumeProt |
        CFastaReader::fForceType;
    
    if (!parse_deflines) {
        flags |= CFastaReader::fNoParseID;
    }

    CFastaReader fasta_reader(line_reader, flags);

    if (id_generator) {
        fasta_reader.SetIDGenerator(*id_generator);
    }

    scope->AddDefaults();
    while (!line_reader.AtEOF()) {

        CRef<CSeq_entry> entry = fasta_reader.ReadOneSeq();

        if (entry == 0) {
            return -1;
        }
        scope->AddTopLevelSeqEntry(*entry);
        CTypeConstIterator<CBioseq> itr(ConstBegin(*entry));
        CRef<CSeq_loc> seqloc(new CSeq_loc());
        seqloc->SetWhole().Assign(*itr->GetId().front());
        seqs.push_back(seqloc);
    }

    return 0;
}
Exemplo n.º 4
0
bool CCSRATestApp::TestApp_Init(void)
{
    SetDiagPostLevel(eDiag_Info);
    const CArgs& args = GetArgs();
    m_Verbose = args["verbose"];
    m_ErrorCount = 0;
    m_Seed = args["seed"]? args["seed"].AsInteger(): int(time(0));
    if ( m_Verbose ) {
        LOG_POST(Info<<"Seed: "<<m_Seed);
    }
    NStr::Split(args["accs"].AsString(), ",", m_Accession);
    if ( args["accs-file"] ) {
        m_Accession.clear();
        CNcbiIstream& in = args["accs-file"].AsInputFile();
        string acc;
        while ( in >> acc ) {
            m_Accession.push_back(acc);
        }
    }
    if ( m_Accession.empty() ) {
        ERR_POST(Fatal<<"empty accession list");
    }
    m_IterCount = args["iter-count"].AsInteger();
    m_IterSize = args["iter-size"].AsInteger();
    m_MaxSpotId.assign(m_Accession.size(), 0);
    m_OM = CObjectManager::GetInstance();
    CCSRADataLoader::RegisterInObjectManager(*m_OM, CObjectManager::eDefault);
    if ( args["shared-scope"] ) {
        m_SharedScope = new CScope(*m_OM);
        m_SharedScope->AddDefaults();
    }
    m_ResetHistory = args["reset-history"];
    m_TestRefSeqs = args["reference-sequences"];
    m_FullSeq = args["full-seq"];
    if ( m_TestRefSeqs ) {
        LoadRefSeqs();
    }
    if ( args["preload"] ) {
        Thread_Run(-1);
    }
    return true;
}
Exemplo n.º 5
0
int CNgAlignTest::Run()
{
    //const CArgs& args = GetArgs();

    CRef<CObjectManager> obj_mgr = CObjectManager::GetInstance();
    CGBDataLoader::RegisterInObjectManager(*obj_mgr);
    m_Scope.Reset(new CScope(*obj_mgr));
    m_Scope->AddDefaults();


    //string TestCaseIni = "/home/boukn/code/toolkit/c++/src/algo/align/uberalign/test/testcases.ini";
    string TestCaseIni = "/panfs/pan1.be-md.ncbi.nlm.nih.gov/genome_maint/work/uberalign/test/testcases.ini";

    CNcbiIfstream TestCaseFile(TestCaseIni.c_str());
    CNcbiRegistry TestCases(TestCaseFile);

    string CasesStr = TestCases.Get("caselist", "cases");
    list<string> Cases;
    NStr::Split(CasesStr, " \t\r\n,", Cases);

    ITERATE(list<string>, CaseIter, Cases) {

        string Type = TestCases.Get(*CaseIter, "type");
        if(Type == "one_to_one") {
            x_OneToOneCase(&TestCases, *CaseIter);
        } else if(Type == "one_to_blastdb") {
            x_OneToBlastDbCase(&TestCases, *CaseIter);
        } else if(Type == "list_to_blastdb") {
            x_ListToBlastDbCase(&TestCases, *CaseIter);
        } else if(Type == "split_one_to_blastdb") {
            x_SplitOneToBlastDbCase(&TestCases, *CaseIter);
        } else if(Type == "split_list_to_blastdb") {
            x_SplitListToBlastDbCase(&TestCases, *CaseIter);
        } else if(Type == "overlap_one_to_blastdb") {
            x_OverlapOneToBlastDbCase(&TestCases, *CaseIter);
        } else if(Type == "overlap_list_to_blastdb") {
            x_OverlapListToBlastDbCase(&TestCases, *CaseIter);
        }

    }
Exemplo n.º 6
0
//  --------------------------------------------------------------------------
int CAsn2FastaApp::Run(void)
//  --------------------------------------------------------------------------
{
	// initialize conn library
	CONNECT_Init(&GetConfig());

    const CArgs&   args = GetArgs();

    // create object manager
    m_Objmgr = CObjectManager::GetInstance();
    if ( !m_Objmgr ) {
        NCBI_THROW(CException, eUnknown,
                   "Could not create object manager");
    }
    CGBDataLoader::RegisterInObjectManager(*m_Objmgr);
    m_Scope.Reset(new CScope(*m_Objmgr));
    m_Scope->AddDefaults();

    // open the output stream
    m_Os = args["o"] ? &(args["o"].AsOutputFile()) : &cout;
    if ( m_Os == 0 ) {
        NCBI_THROW(CException, eUnknown, "Could not open output stream");
    }

    auto_ptr<CObjectIStream> is;
    is.reset( x_OpenIStream( args ) );
    if (is.get() == NULL) {
        string msg = args["i"]? "Unable to open input file" + args["i"].AsString() :
                        "Unable to read data from stdin";
        NCBI_THROW(CException, eUnknown, msg);
    }

    m_DeflineOnly = args["defline-only"];

    if ( args["batch"] ) {
        CGBReleaseFile in(*is.release());
        in.RegisterHandler(this);
        in.Read();  // HandleSeqEntry will be called from this function
    }
    else {

        if ( args["id"] ) {

            //
            //  Implies gbload; otherwise this feature would be pretty
            //  useless...
            //
            m_Scope->AddDefaults();
            string seqID = args["id"].AsString();
            HandleSeqID( seqID );

        } else {
            string asn_type = args["type"].AsString();
            CSeq_entry_Handle seh;

            if ( asn_type == "seq-entry" ) {
                //
                //  Straight through processing: Read a seq_entry, then process
                //  a seq_entry:
                //
                seh = ObtainSeqEntryFromSeqEntry(*is);
                while (seh) {
                    try {
                        HandleSeqEntry(seh);
                    }
                    catch (...) {
                        cerr << "Resolution error: Sequence dropped." << endl;
                    }
                    m_Scope->RemoveTopLevelSeqEntry(seh);
                    seh = ObtainSeqEntryFromSeqEntry(*is);
                }
                return 0;
			}
			else if ( asn_type == "bioseq" ) {				
				//
                //  Read object as a bioseq, wrap it into a seq_entry, then
                //  process the wrapped bioseq as a seq_entry:
				//
                seh = ObtainSeqEntryFromBioseq(*is);
                if ( !seh ) {
                    NCBI_THROW(CException, eUnknown,
                               "Unable to construct Seq-entry object" );
                }
                HandleSeqEntry(seh);
			}
			else if ( asn_type == "bioseq-set" ) {
				//
				//  Read object as a bioseq_set, wrap it into a seq_entry, then
				//  process the wrapped bioseq_set as a seq_entry:
				//
                seh = ObtainSeqEntryFromBioseqSet(*is);
                if ( !seh ) {
                    NCBI_THROW(CException, eUnknown,
                               "Unable to construct Seq-entry object" );
                }
                HandleSeqEntry(seh);
			}
            else if ( asn_type == "any" ) {
                //
                //  Try the first three in turn:
                //
                size_t streampos = is->GetStreamPos();
                while (!is->EndOfData()) {
                    seh = ObtainSeqEntryFromSeqEntry(*is);
                    if (!seh) {
                        if (is->EndOfData()) {
                            break;
                        }
                        is->ClearFailFlags(-1);
                        is->SetStreamPos(streampos);
                        seh = ObtainSeqEntryFromBioseqSet(*is);
                    }
                    if (!seh) {
                        if (is->EndOfData()) {
                            break;
                        }
                        is->ClearFailFlags(-1);
                        is->SetStreamPos(streampos);
                        seh = ObtainSeqEntryFromBioseq(*is);
                    }
                    if (!seh) {
                        NCBI_THROW(CException, eUnknown,
                            "Unable to construct Seq-entry object" );
                    }
                    HandleSeqEntry(seh);
                    m_Scope->RemoveTopLevelSeqEntry(seh);
                    streampos = is->GetStreamPos();
                }
            }
        }
    }

    m_Os->flush();

    is.reset();
    return 0;
}