コード例 #1
0
ファイル: igblast.cpp プロジェクト: jackgopack4/pico-blast
CIgAnnotationInfo::CIgAnnotationInfo(CConstRef<CIgBlastOptions> &ig_opt)
{
    vector<string> lines;

    // read domain info from pdm or ndm file
    const string suffix = (ig_opt->m_IsProtein) ? ".pdm." : ".ndm.";
    string fn(SeqDB_ResolveDbPath(ig_opt->m_IgDataPath + "/" + ig_opt->m_Origin + "/" 
                               + ig_opt->m_Origin + suffix + ig_opt->m_DomainSystem));
    if (fn == "") {
        NCBI_THROW(CBlastException,  eInvalidArgument, 
              "Domain annotation data file could not be found in [internal_data] directory");
    }
    s_ReadLinesFromFile(fn, lines);
    int index = 0;
    ITERATE(vector<string>, l, lines) {
        vector<string> tokens;
        NStr::Tokenize(*l, " \t\n\r", tokens, NStr::eMergeDelims);
        if (!tokens.empty()) {
            m_DomainIndex[tokens[0]] = index;
            for (int i=1; i<11; ++i) {
                m_DomainData.push_back(NStr::StringToInt(tokens[i]));
            }
            index += 10;
            m_DomainChainType[tokens[0]] = tokens[11];
            int frame = NStr::StringToInt(tokens[12]);
            if (frame != -1) {
                m_FrameOffset[tokens[0]] = frame;
            }
        } 
    }
コード例 #2
0
ファイル: data4xml2format.cpp プロジェクト: DmitrySigaev/ncbi
void
CCmdLineBlastXML2ReportData::x_InitCommon(
	const CSearchResults & results,
    CConstRef<CBlastOptions> opts)
{
	if(opts.Empty()) {
		NCBI_THROW(CException, eUnknown, "blastxml2: Empty blast options");
	}

	if(m_Scope.Empty()) {
		NCBI_THROW(CException, eUnknown, "blastxml2: Empty scope");
	}

	x_FillScoreMatrix(m_Options->GetMatrixName());

	string resolved = SeqDB_ResolveDbPath("taxdb.bti");
	if(!resolved.empty()) {
		m_TaxDBFound = true;
	}

  	m_isIterative  = opts->IsIterativeSearch();
}
コード例 #3
0
ファイル: seqdbtax.cpp プロジェクト: svn2github/ncbi_tk
CTaxDBFileInfo::CTaxDBFileInfo()
    : m_AllTaxidCount(0),
      m_IndexPtr(NULL),
      m_DataPtr(NULL),
      m_DataFileSize(0),
      m_MissingDB(false)
{

    // It is reasonable for this database to not exist.
    m_IndexFN =  SeqDB_ResolveDbPath("taxdb.bti");

    if (m_IndexFN.size()) {
        m_DataFN = m_IndexFN;
        m_DataFN[m_DataFN.size()-1] = 'd';
    }
    
    if (! (m_IndexFN.size() &&
           m_DataFN.size()  &&
           CFile(m_IndexFN).Exists() &&
           CFile(m_DataFN).Exists())) {
        m_MissingDB = true;
        return;
    }
    
    // Size for header data plus one taxid object.
    
    Uint4 data_start = (4 +    // magic
                        4 +    // taxid count
                        16);   // 4 reserved fields
    
    Uint4 idx_file_len = (Uint4) CFile(m_IndexFN).GetLength();
    
    if (idx_file_len < (data_start + sizeof(CSeqDBTaxId))) {
        m_MissingDB = true;
        return;
    }
    
    m_IndexFileMap.reset(new CMemoryFile(m_IndexFN));
    
    m_IndexFileMap->Map();

    // Last check-up of the database validity
    
    
    Uint4 * magic_num_ptr = (Uint4 *)m_IndexFileMap->GetPtr();
    
    const unsigned TAX_DB_MAGIC_NUMBER = 0x8739;
    
    if (TAX_DB_MAGIC_NUMBER != SeqDB_GetStdOrd(magic_num_ptr ++)) {
        m_MissingDB = true;
        m_IndexFileMap.reset();
        ERR_POST("Error: Tax database file has wrong magic number.");
        return;
    }
    
    m_AllTaxidCount = SeqDB_GetStdOrd(magic_num_ptr ++);
    
    // Skip the four reserved fields
    magic_num_ptr += 4;
    
    int taxid_array_size = int((idx_file_len - data_start)/sizeof(CSeqDBTaxId));
    
    if (taxid_array_size != m_AllTaxidCount) {
        m_MissingDB = true;
        m_IndexFileMap.reset();
        ERR_POST("SeqDB: Taxid metadata indicates (" << m_AllTaxidCount
                   << ") entries but file has room for (" << taxid_array_size
                   << ").");
        
        if (taxid_array_size < m_AllTaxidCount) {
            m_AllTaxidCount = taxid_array_size;
        }
        return;
    }
    
    m_DataFileMap.reset(new CMemoryFile(m_DataFN));

    m_DataPtr = (char *) (m_DataFileMap->GetPtr());
    m_DataFileSize = m_DataFileMap->GetSize();
    m_IndexPtr = (CSeqDBTaxId*) magic_num_ptr;
    
}