Example #1
0
LIB_EXPORT rc_t CC SRAMgrMakeReadWithDir ( const SRAMgr **mgrp,
        struct KDirectory const *wd )
{
    rc_t rc;

    if ( mgrp == NULL )
        rc = RC ( rcSRA, rcMgr, rcConstructing, rcParam, rcNull );
    else
    {
        const VDBManager *vmgr;
        rc = VDBManagerMakeRead ( & vmgr, wd );
        if ( rc == 0 )
        {
            SRAMgr *mgr;
            rc = SRAMgrMake ( & mgr, vmgr, wd );
            if ( rc == 0 )
            {
                * mgrp = mgr;
                return 0;
            }

            VDBManagerRelease ( vmgr );
        }

        * mgrp = NULL;
    }

    return rc;
}
Example #2
0
static rc_t ref_walker_init( struct ref_walker * self )
{
    rc_t rc = KDirectoryNativeDir( &self->dir );
    if ( rc == 0 )
        rc = VDBManagerMakeRead ( &self->vmgr, self->dir );
    if ( rc == 0 )
        rc = VDBManagerMakeSRASchema( self->vmgr, &self->vschema );
    if ( rc == 0 )
        rc = AlignMgrMakeRead ( &self->amgr );
    if ( rc == 0 )
        rc =  VFSManagerMake ( &self->vfs_mgr );        
    if ( rc == 0 )
        rc = VNamelistMake ( &self->sources, 10 );

    self->cb_block.data = self;
    self->cb_block.destroy = NULL;
    self->cb_block.populate = populate_data;
    self->cb_block.alloc_size = alloc_size;
    self->cb_block.fixed_size = 0;

    BSTreeInit( &self->regions );
    self->primary_alignments = true;
    
    if ( rc != 0 )
        ref_walker_release( self );
    return rc;
}
Example #3
0
rc_t report_on_reference( Args * args, bool extended )
{
    uint32_t count;
    rc_t rc = ArgsParamCount( args, &count );
    if ( rc != 0 )
    {
        LOGERR( klogInt, rc, "ArgsParamCount() failed" );
    }
    else
    {
        KDirectory *dir; 
        rc = KDirectoryNativeDir( &dir );
        if ( rc != 0 )
        {
            LOGERR( klogInt, rc, "KDirectoryNativeDir() failed" );
        }
        else
        {
            const VDBManager *vdb_mgr;
            rc = VDBManagerMakeRead ( &vdb_mgr, dir );
            if ( rc != 0 )
            {
                LOGERR( klogInt, rc, "VDBManagerMakeRead() failed" );
            }
            else
            {
                VFSManager * vfs_mgr;
                rc =  VFSManagerMake ( &vfs_mgr );
                if ( rc != 0 )
                {
                    (void)LOGERR( klogErr, rc, "cannot make vfs-manager" );
                }
                else
                {
                    uint32_t idx;
                    for ( idx = 0; idx < count && rc == 0; ++idx )
                    {
                        const char *param = NULL;
                        rc = ArgsParamValue( args, idx, &param );
                        if ( rc != 0 )
                        {
                            LOGERR( klogInt, rc, "ArgsParamvalue() failed" );
                        }
                        else
                        {
                            /* rc value not used, because it can be something that has no references */
                            report_references( vdb_mgr, vfs_mgr, param, extended );
                        }
                    }
                    VFSManagerRelease ( vfs_mgr );
                }
                VDBManagerRelease( vdb_mgr );
            }
            KDirectoryRelease( dir );
        }
    }
    return rc;
}
Example #4
0
rc_t report_deletes( Args * args, uint32_t min_len )
{
    uint32_t count;
    rc_t rc = ArgsParamCount( args, &count );
    if ( rc != 0 )
    {
        LOGERR( klogInt, rc, "ArgsParamCount() failed" );
    }
    else
    {
        KDirectory *dir; 
        rc = KDirectoryNativeDir( &dir );
        if ( rc != 0 )
        {
            LOGERR( klogInt, rc, "KDirectoryNativeDir() failed" );
        }
        else
        {
            const VDBManager *vdb_mgr;
            rc = VDBManagerMakeRead ( &vdb_mgr, dir );
            if ( rc != 0 )
            {
                LOGERR( klogInt, rc, "VDBManagerMakeRead() failed" );
            }
            else
            {
                VFSManager * vfs_mgr;
                rc =  VFSManagerMake ( &vfs_mgr );
                if ( rc != 0 )
                {
                    (void)LOGERR( klogErr, rc, "cannot make vfs-manager" );
                }
                else
                {
                    uint32_t idx;
                    for ( idx = 0; idx < count && rc == 0; ++idx )
                    {
                        const char *param = NULL;
                        rc = ArgsParamValue( args, idx, (const void **)&param );
                        if ( rc != 0 )
                        {
                            LOGERR( klogInt, rc, "ArgsParamvalue() failed" );
                        }
                        else
                        {
                            rc = report_deletes_spec( vdb_mgr, vfs_mgr, param, min_len );
                        }
                    }
                    VFSManagerRelease ( vfs_mgr );
                }
                VDBManagerRelease( vdb_mgr );
            }
            KDirectoryRelease( dir );
        }
    }
    return rc;
}
Example #5
0
void CVDBMgr::x_Init(void)
{
    if ( rc_t rc = VDBManagerMakeRead(x_InitPtr(), 0) ) {
        *x_InitPtr() = 0;
        NCBI_THROW2(CSraException, eInitFailed,
                    "Cannot open VDBManager", rc);
    }
    uint32_t sdk_ver;
    if ( rc_t rc = VDBManagerVersion(*this, &sdk_ver) ) {
        NCBI_THROW2(CSraException, eInitFailed,
                    "Cannot get VDBManager version", rc);
    }
    CKNSManager kns_mgr(CVFSManager(*this));
    CNcbiOstrstream str;
    CNcbiApplication* app = CNcbiApplication::Instance();
    if ( app ) {
        str << app->GetAppName() << ": " << app->GetVersion().Print() << "; ";
    }
#if NCBI_PACKAGE
    str << "Package: " << NCBI_PACKAGE_NAME << ' ' <<
        NCBI_PACKAGE_VERSION << "; ";
#endif
    str << "C++ ";
#ifdef NCBI_PRODUCTION_VER
    str << NCBI_PRODUCTION_VER << "/";
#endif
#ifdef NCBI_DEVELOPMENT_VER
    str << NCBI_DEVELOPMENT_VER;
#endif
    string prefix = CNcbiOstrstreamToString(str);
    KNSManagerSetUserAgent(kns_mgr, "%s; SRA Toolkit %V",
                           prefix.c_str(),
                           sdk_ver);

    // redirect VDB log to C++ Toolkit
    if ( s_GetDiagHandler() ) {
        KLogInit();
        KLogLevelSet(klogDebug);
        KLogLibHandlerSet(VDBLogWriter, 0);
    }

    if ( app ) {
        string host = app->GetConfig().GetString("CONN", "HTTP_PROXY_HOST", kEmptyStr);
        int port = app->GetConfig().GetInt("CONN", "HTTP_PROXY_PORT", 0);
        if ( !host.empty() && port != 0 ) {
            if ( rc_t rc = KNSManagerSetHTTPProxyPath(kns_mgr, "%s:%d", host.c_str(), port) ) {
                NCBI_THROW2(CSraException, eInitFailed,
                            "Cannot set KNSManager proxy parameters", rc);
            }
            KNSManagerSetHTTPProxyEnabled(kns_mgr, true);
        }
    }
}
Example #6
0
rc_t make_trans_ctx( trans_ctx * ctx, trans_opt * opt, bool open_reference )
{
    rc_t rc = AlignMgrMakeRead ( &ctx->almgr );
    if ( rc != 0 )
        LOGERR( klogInt, rc, "AlignMgrMake() failed" );

    if ( rc == 0 )
    {
        rc = KDirectoryNativeDir( &ctx->dir );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "KDirectoryNativeDir() failed" );
    }

    if ( rc == 0 )
    {
        rc = VDBManagerMakeRead ( &ctx->vdb_mgr, ctx->dir );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "VDBManagerMakeRead() failed" );
    }

    if ( rc == 0 )
    {
        if ( opt->fname != NULL )
        {
            rc = VDBManagerOpenDBRead ( ctx->vdb_mgr, &ctx->db, NULL, "%s", opt->fname );
            if ( rc != 0 )
                LOGERR( klogInt, rc, "VDBManagerOpenDBRead() failed" );
        }
        else
            rc = RC ( rcApp, rcArgv, rcAccessing, rcParam, rcNull );
    }

    if ( rc == 0 )
    {
        rc = ReferenceList_MakeDatabase( &ctx->ref_list, ctx->db,
                                         ereferencelist_4na |
                                         ereferencelist_usePrimaryIds,
                                         0, NULL, 0 );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "ReferenceList_MakeDatabase() failed" );
    }

    if ( rc == 0 && open_reference )
    {
        OUTMSG(( "looking for reference '%s'\n", opt->ref_name ));
        rc = ReferenceList_Find( ctx->ref_list, &ctx->ref_obj, opt->ref_name, string_size( opt->ref_name ) );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "ReferenceList_Find() failed" );
    }

    return rc;
}
Example #7
0
static rc_t cg_dump_src_dst_rows( cg_dump_opts * opts, const char * src, cg_dump_ctx * cg_ctx )
{
    rc_t rc = KDirectoryNativeDir( &cg_ctx->dir );
    if ( rc != 0 )
    {
        (void)LOGERR( klogErr, rc, "cannot create internal directory object" );
    }
    else
    {
        const VDBManager * mgr;
        rc = VDBManagerMakeRead ( &mgr, cg_ctx->dir );
        if ( rc != 0 )
        {
            (void)LOGERR( klogErr, rc, "cannot create vdb-manager" );
        }
        else
        {
            int path_type = ( VDBManagerPathType ( mgr, "%s", src ) & ~ kptAlias );
            if ( path_type != kptDatabase )
            {
                rc = RC( rcExe, rcNoTarg, rcReading, rcParam, rcInvalid );
                if ( path_type == kptNotFound )
                {
                    (void)LOGERR( klogErr, rc, "the source object cannot be found" );
                }
                else
                {
                    (void)LOGERR( klogErr, rc, "source cannot be used" );
                    KOutMsg( "it is instead: '%s'\n", pathtype_2_pchar( path_type ) );
                }
            }
            else
            {
                rc = cg_dump_src_dst_rows_vdb( opts, mgr, src, cg_ctx ); /* <================== */
            }
            VDBManagerRelease( mgr );
        }
        KDirectoryRelease( cg_ctx->dir );
    }
    return rc;
}
Example #8
0
static rc_t DumpSchema( const context *ctx )
{
    KDirectory *my_dir;
    rc_t rc = KDirectoryNativeDir ( &my_dir );
    display_rescode( rc, "failed to open native dir", NULL );
    if ( rc == 0 )
    {
        const VDBManager *my_manager;
        rc = VDBManagerMakeRead ( &my_manager, my_dir );
        display_rescode( rc, "failed to make manager", NULL );
        if ( rc == 0 )
        {
            VSchema *my_schema;
            rc = VDBManagerMakeSchema( my_manager, &my_schema );
            display_rescode( rc, "failed to make schema", NULL );
            if ( rc == 0 )
            {
                rc = for_each_v_name( ctx->include_files, my_schema, add_include );
                if ( rc == 0 )
                {
                    rc = for_each_v_name( ctx->src_files, my_schema, add_source );
                    if ( rc == 0 )
                    {
                        rc = DumpSchema_to( my_schema, ctx );
                        if ( rc == 0 )
                            rc = WriteDependency( my_schema, ctx );
                    }
                }
                VSchemaRelease( my_schema );
            }
            VDBManagerRelease( my_manager );
        }
        KDirectoryRelease( my_dir );
    }
    return rc;
}
Example #9
0
static rc_t ShowModules(const KConfig* cfg, const Params* prm) {
    rc_t rc = 0;
#ifdef _STATIC
    OUTMSG(("<!-- Modules are not used in static build -->\n"));
#else
    const VDBManager* mgr = NULL;
    KNamelist* list = NULL;
    OUTMSG(("<!-- Modules -->\n"));
    rc = VDBManagerMakeRead(&mgr, NULL);
    DISP_RC(rc, "while calling VDBManagerMakeRead");
    if (rc == 0) {
        rc = VDBManagerListExternalSchemaModules(mgr, &list);
        DISP_RC(rc, "while calling VDBManagerListExternalSchemaModules");
    }
    if (rc == 0) {
        uint32_t count = 0;
        rc = KNamelistCount(list, &count);
        DISP_RC(rc, "while calling KNamelistCount "
            "on VDBManagerListExternalSchemaModules result");
        if (rc == 0) {
            int64_t i = 0;
            for (i = 0; i < count && rc == 0; ++i) {
                const char* name = NULL;
                rc = KNamelistGet(list, i, &name);
                DISP_RC(rc, "while calling KNamelistGet "
                    "on VDBManagerListExternalSchemaModules result");
                if (rc == 0) {
                    OUTMSG(("%s\n", name));
                }
            }
        }
    }
    OUTMSG(("\n"));
    RELEASE(KNamelist, list);
    RELEASE(VDBManager, mgr);
#endif
#if 0
    KDirectory* dir = NULL;
    const char* paths[] = { "vdb/module/paths", "vdb/wmodule/paths" };
    int i = 0;
    assert(cfg);
    for (i = 0; i < sizeof paths / sizeof paths[0] && rc == 0; ++i) {
        const KConfigNode* node = NULL;
        if (rc == 0) {
            const char* path = paths[i];
            rc = KConfigOpenNodeRead(cfg, &node, path);
            if (rc != 0) {
                if (GetRCState(rc) == rcNotFound) {
                    rc = 0;
                    continue;
                }
                else {  DISP_RC(rc, path); }
            }
            else {
                char buf[PATH_MAX + 1];
                size_t num_read = 0;
                size_t remaining = 0;
                rc = KConfigNodeRead(node, 0,
                    buf, sizeof buf, &num_read, &remaining);
                assert(remaining == 0);
                assert(num_read <= sizeof buf);
                DISP_RC(rc, path);
                if (rc == 0) {
                    if (num_read < sizeof buf) {
                        buf[num_read] = '\0';
                        if (dir == NULL)
                        {   rc = KDirectoryNativeDir(&dir); }
                        if (rc == 0) {
                            OUTMSG(("%s = %s\n", path, buf));
                            rc = ShowModDir(dir, buf);
                            if (rc == 0)
                            {   OUTMSG(("\n")); }
                        }
                    }
                }
            }
            RELEASE(KConfigNode, node);
        }
    }
    RELEASE(KDirectory, dir);
#endif
    return rc;
}
Example #10
0
static rc_t align_info(const Params* prm) {
    rc_t rc = 0;

    const VDatabase* db = NULL;
    const VDBManager* mgr = NULL;
    const KDBManager *kmgr = NULL;
    VSchema* schema = NULL;
    bool is_db = false;

    if (prm == NULL)
    {   return RC(rcExe, rcQuery, rcExecuting, rcParam, rcNull); }

    if (rc == 0) {
        rc = VDBManagerMakeRead(&mgr, NULL);
        DISP_RC(rc, "while calling VDBManagerMakeRead");
    }

    if (rc == 0) {
        rc = VDBManagerOpenKDBManagerRead(mgr, &kmgr);
        DISP_RC(rc, "while calling VDBManagerOpenKDBManagerRead");
    }

    if (rc == 0) {
        rc = VDBManagerMakeSRASchema(mgr, &schema);
        DISP_RC(rc, "while calling VDBManagerMakeSRASchema");
    }

    if (rc == 0) {
/*      const char path[] = "/panfs/pan1/trace_work/scratch/XXX000013"; */
        rc = VDBManagerOpenDBRead(mgr, &db, schema, prm->dbPath);
        if (rc == 0) {
            is_db = true;
        }
        else if (rc == SILENT_RC(rcDB, rcMgr, rcOpening, rcDatabase, rcIncorrect)) {
            PLOGMSG(klogWarn, (klogWarn,
                "'$(path)' is not a database", "path=%s", prm->dbPath));
            rc = 0;
        }
        else {
            PLOGERR(klogErr,
                (klogErr, rc, "$(path)", "path=%s", prm->dbPath));
        }
    }

    if (is_db) {
        if (rc == 0) {
            if (prm->paramRef) {
                const VDBDependencies* dep = NULL;
                uint32_t count = 0;
                int i = 0;
                rc = VDatabaseListDependencies(db, &dep, false);
                DISP_RC2(rc, prm->dbPath,
                    "while calling VDatabaseListDependencies");
                if (rc == 0) {
                    rc = VDBDependenciesCount(dep, &count);
                    DISP_RC2(rc, prm->dbPath,
                        "while calling VDBDependenciesCount");
                }
                for (i = 0; i < count && rc == 0; ++i) {
                    bool circular = false;
                    const char* name = NULL;
                    const char* path = NULL;
                    const char* remote = NULL;
                    bool local = false;
                    const char* seqId = NULL;
                    rc = VDBDependenciesCircular(dep, &circular, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesCircular");
                        break;
                    }
                    rc = VDBDependenciesName(dep, &name, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesName");
                        break;
                    }
                    rc = VDBDependenciesPath(dep, &path, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesPath");
                        break;
                    }
                    rc = VDBDependenciesLocal(dep, &local, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesLocal");
                        break;
                    }
                    rc = VDBDependenciesSeqId(dep, &seqId, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesSeqId");
                        break;
                    }
                    rc = VDBDependenciesPathRemote(dep, &remote, i);
                    if (rc != 0) {
                        DISP_RC2(rc, prm->dbPath,
                            "while calling VDBDependenciesRemote");
                        break;
                    }
                    OUTMSG(("%s,%s,%s,%s", seqId, name,
                        (circular ? "true" : "false"),
                        (local ? "local" : "remote")));
                    if (path && path[0]) {
                        OUTMSG((":%s", path));
                    }
                    else if (remote && remote[0]) {
                        OUTMSG(("::%s", remote));
                    }
                    OUTMSG(("\n"));
                }
                DESTRUCT(VDBDependencies, dep);
            }

            if (prm->paramBamHeader) {
                rc_t rc3 = bam_header(db);
                if (rc3 != 0 && rc == 0)
                {   rc = rc3; }
            }

            if (prm->paramQuality) {
                rc_t rc3 = qual_stats(prm, db);
                if (rc3 != 0 && rc == 0)
                {   rc = rc3; }
            }
        }

    }

    DESTRUCT(VSchema, schema);
    DESTRUCT(KDBManager, kmgr);
    DESTRUCT(VDBManager, mgr);
    DESTRUCT(VDatabase, db);

    return rc;
}
Example #11
0
rc_t run(const TestCase& test_case)
{
    rc_t rc;
    KDirectory * cur_dir;
    const VDBManager * manager;
    const VDatabase * database;
    const VTable * table;
    const VCursor * cursor;
    uint32_t name_idx;
    uint32_t name_range_idx;
    
    rc = KDirectoryNativeDir( &cur_dir );
    if ( rc != 0 )
        LOGERR( klogInt, rc, "KDirectoryNativeDir() failed" );
    else
    {
        rc = VDBManagerMakeRead ( &manager, cur_dir );
        if ( rc != 0 )
            LOGERR( klogInt, rc, "VDBManagerMakeRead() failed" );
        else
        {
            rc = VDBManagerOpenDBRead( manager, &database, NULL, "%s", test_case.path );
            if (rc != 0)
                LOGERR( klogInt, rc, "VDBManagerOpenDBRead() failed" );
            else
            {
                rc = VDatabaseOpenTableRead( database, &table, "%s", TABLE_NAME );
                if ( rc != 0 )
                    LOGERR( klogInt, rc, "VDatabaseOpenTableRead() failed" );
                else
                {
                    rc = VTableCreateCursorRead( table, &cursor );
                    if ( rc != 0 )
                        LOGERR( klogInt, rc, "VTableCreateCursorRead() failed" );
                    else
                    {
                        /* add columns to cursor */
                        rc = VCursorAddColumn( cursor, &name_idx, "(utf8)NAME" );
                        if ( rc != 0 )
                            LOGERR( klogInt, rc, "VCursorAddColumn() failed" );
                        else
                        {
                            rc = VCursorAddColumn( cursor, &name_range_idx, "NAME_RANGE" );
                            if ( rc != 0 )
                                LOGERR( klogInt, rc, "VCursorAddColumn() failed" );
                            else
                            {
                                rc = VCursorOpen( cursor );
                                if (rc != 0)
                                    LOGERR( klogInt, rc, "VCursorOpen() failed" );
                                else
                                    rc = runChecks( test_case, cursor, name_idx, name_range_idx );
                            }
                        }
                        VCursorRelease( cursor );
                    }
                    VTableRelease( table );
                }
                VDatabaseRelease( database );
            }
            
            VDBManagerRelease( manager );
        }
        KDirectoryRelease( cur_dir );
    }
    return rc;
}
Example #12
0
/**
 * returns true if accession is good
 */
bool checkAccession ( const char * accession, const CheckCorruptConfig * config )
{
    rc_t rc;
    KDirectory * cur_dir;
    const VDBManager * manager;
    const VDatabase * database;
    const VTable * pa_table;
    const VTable * sa_table;
    const VTable * seq_table;

    const VCursor * pa_cursor;
    const VCursor * sa_cursor;
    const VCursor * seq_cursor;

    rc = KDirectoryNativeDir( &cur_dir );
    if ( rc != 0 )
        PLOGERR( klogInt, (klogInt, rc, "$(ACC) KDirectoryNativeDir() failed", "ACC=%s", accession));
    else
    {
        rc = VDBManagerMakeRead ( &manager, cur_dir );
        if ( rc != 0 )
            PLOGERR( klogInt, (klogInt, rc, "$(ACC) VDBManagerMakeRead() failed", "ACC=%s", accession));
        else
        {
            int type = VDBManagerPathType ( manager, "%s", accession );
            if ( ( type & ~ kptAlias ) != kptDatabase )
                PLOGMSG (klogInfo, (klogInfo, "$(ACC) SKIPPING - can't be opened as a database", "ACC=%s", accession));
            else
            {
                rc = VDBManagerOpenDBRead( manager, &database, NULL, "%s", accession );
                if (rc != 0)
                    PLOGERR( klogInt, (klogInt, rc, "$(ACC) VDBManagerOpenDBRead() failed", "ACC=%s", accession));
                else
                {
                    rc = VDatabaseOpenTableRead( database, &pa_table, "%s", "PRIMARY_ALIGNMENT" );
                    if ( rc != 0 )
                    {
                        PLOGMSG (klogInfo, (klogInfo, "$(ACC) SKIPPING - failed to open PRIMARY_ALIGNMENT table", "ACC=%s", accession));
                        rc = 0;
                    }
                    else
                    {
                        rc = VTableCreateCursorRead( pa_table, &pa_cursor );
                        if ( rc != 0 )
                            PLOGERR( klogInt, (klogInt, rc, "$(ACC) VTableCreateCursorRead() failed for PRIMARY_ALIGNMENT cursor", "ACC=%s", accession));
                        else
                        {
                            rc = VDatabaseOpenTableRead( database, &sa_table, "%s", "SECONDARY_ALIGNMENT" );
                            if ( rc != 0 )
                            {
                                PLOGMSG (klogInfo, (klogInfo, "$(ACC) SKIPPING - failed to open SECONDARY_ALIGNMENT table", "ACC=%s", accession));
                                rc = 0;
                            }
                            else
                            {
                                rc = VTableCreateCursorRead( sa_table, &sa_cursor );
                                if ( rc != 0 )
                                    PLOGERR( klogInt, (klogInt, rc, "$(ACC) VTableCreateCursorRead() failed for SECONDARY_ALIGNMENT cursor", "ACC=%s", accession));
                                else
                                {
                                    rc = VDatabaseOpenTableRead( database, &seq_table, "%s", "SEQUENCE" );
                                    if ( rc != 0 )
                                    {
                                        PLOGMSG (klogInfo, (klogInfo, "$(ACC) SKIPPING - failed to open SEQUENCE table", "ACC=%s", accession));
                                        rc = 0;
                                    }
                                    else
                                    {
                                        rc = VTableCreateCursorRead( seq_table, &seq_cursor );
                                        if ( rc != 0 )
                                            PLOGERR( klogInt, (klogInt, rc, "VTableCreateCursorRead() failed for SEQUENCE cursor", "ACC=%s", accession));
                                        else
                                        {
                                            try {
                                                runChecks( accession, config, pa_cursor, sa_cursor, seq_cursor );
                                            } catch ( VDB_ERROR & x ) {
                                                PLOGERR (klogErr, (klogInfo, x.rc, "$(ACC) VDB error: $(MSG)", "ACC=%s,MSG=%s", accession, x.msg));
                                                rc = 1;
                                            } catch ( VDB_ROW_ERROR & x ) {
                                                PLOGERR (klogErr, (klogInfo, x.rc, "$(ACC) VDB error: $(MSG) row_id: $(ROW_ID)", "ACC=%s,MSG=%s,ROW_ID=%ld", accession, x.msg, x.row_id));
                                                rc = 1;
                                            } catch ( DATA_ERROR & x ) {
                                                KOutMsg("%s\n", accession);
                                                PLOGMSG (klogInfo, (klogInfo, "$(ACC) Invalid data: $(MSG) ", "ACC=%s,MSG=%s", accession, x.msg.c_str()));
                                                rc = 1;
                                            }
                                            VCursorRelease( seq_cursor );
                                        }
                                        VTableRelease( seq_table );
                                    }
                                    VCursorRelease( sa_cursor );
                                }
                                VTableRelease( sa_table );
                            }
                            VCursorRelease( pa_cursor );
                        }
                        VTableRelease( pa_table );
                    }
                    VDatabaseRelease( database );
                }
            }
            VDBManagerRelease( manager );
        }
        KDirectoryRelease( cur_dir );
    }
    return rc == 0;
}
Example #13
0
rc_t init_vdb_objects (
    VDBManager const** mgr,
    VDatabase const** db,
    VTable const** table_ref,
    VTable const** table_pa,
    VCursor const** cursor_ref,
    VCursor const** cursor_pa,
    char const* db_path,
    char const* const* column_names_ref, uint32_t* column_index_ref, size_t column_count_ref,
    char const* const* column_names_pa, uint32_t* column_index_pa, size_t column_count_pa,
    char* error_buf,
    size_t error_buf_size
    )
{
    rc_t rc = 0;

    rc = VDBManagerMakeRead ( mgr, NULL );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VDBManagerMakeRead failed with error: 0x%08x (%u) [%R]",
            rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = VDBManagerOpenDBRead ( *mgr, db, NULL, db_path );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VDBManagerOpenDBRead(%s) failed with error: 0x%08x (%u) [%R]",
            db_path, rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = VDatabaseOpenTableRead ( *db, table_ref, "REFERENCE" );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VDatabaseOpenTableRead(REFERENCE) failed with error: 0x%08x (%u) [%R]",
            rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = VDatabaseOpenTableRead ( *db, table_pa, "PRIMARY_ALIGNMENT" );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VDatabaseOpenTableRead(PRIMARY_ALIGNMENT) failed with error: 0x%08x (%u) [%R]",
            rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = VTableCreateCursorRead ( *table_ref, cursor_ref );
    /*rc = VTableCreateCachedCursorRead ( *table_ref, cursor_ref, (size_t)64 << 30 );*/
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VTableCreateCursorRead(ref) failed with error: 0x%08x (%u) [%R]",
            rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = init_column_index ( *cursor_ref, column_names_ref, column_index_ref, column_count_ref, error_buf, error_buf_size );
    if ( rc != 0 )
        return rc;

    rc = VCursorOpen ( *cursor_ref );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VCursorOpen(ref) failed with error: 0x%08x (%u) [%R]", rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = VTableCreateCursorRead ( *table_pa, cursor_pa );
    /*rc = VTableCreateCachedCursorRead ( *table_pa, cursor_pa, (size_t)64 << 30 );*/
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VTableCreateCursorRead(pa) failed with error: 0x%08x (%u) [%R]", rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    rc = init_column_index ( *cursor_pa, column_names_pa, column_index_pa, column_count_pa, error_buf, error_buf_size );
    if ( rc != 0 )
        return rc;

    rc = VCursorOpen ( *cursor_pa );
    if ( rc != 0 )
    {
        rc_t res = string_printf ( error_buf, error_buf_size, NULL,
            "ERROR: VCursorOpen(pa) failed with error: 0x%08x (%u) [%R]", rc, rc, rc);
        if (res == rcBuffer || res == rcInsufficient)
            error_buf [ error_buf_size - 1 ] = '\0';

        return rc;
    }

    return rc;
}