Example #1
0
rc_t SRALoaderFmtMake(SRALoaderFmt **self, const SRALoaderConfig *config)
{
    rc_t rc = 0;
    FastqLoaderFmt* fmt;
    const PlatformXML* platform;
    const ProcessingXML* processing;

    if( self == NULL || config == NULL ) {
        return RC(rcSRA, rcFormatter, rcConstructing, rcParam, rcNull);
    }
    *self = NULL;

    if( (rc = Experiment_GetProcessing(config->experiment, &processing)) != 0 ||
        (rc = Experiment_GetPlatform(config->experiment, &platform)) != 0 ) {
        return rc;
    }
    fmt = calloc(1, sizeof(*fmt));
    if(fmt == NULL) {
        rc = RC(rcSRA, rcFormatter, rcConstructing, rcMemory, rcExhausted);
        LOGERR(klogInt, rc, "failed to initialize; out of memory");
        return rc;
    }
    if( platform->id == SRA_PLATFORM_454 ) {
        if( rc == 0 && (rc = SRAWriter454_Make(&fmt->w454, config)) != 0 ) {
            LOGERR(klogInt, rc, "failed to initialize 454 writer");
        }
    } else if( platform->id == SRA_PLATFORM_ION_TORRENT ) {
        if( rc == 0 && (rc = SRAWriterIonTorrent_Make(&fmt->wIonTorrent, config)) != 0 ) {
            LOGERR(klogInt, rc, "failed to initialize Ion Torrent writer");
        }
    } else if(   (rc = SRAWriterIllumina_Make(&fmt->wIllumina, config)) != 0 ) {
        LOGERR(klogInt, rc, "failed to initialize Illumina writer");
    }
    if( rc == 0 && (rc = SRALoaderFmtInit(&fmt->dad, (const SRALoaderFmt_vt*)&vtFastqLoaderFmt)) != 0 ) {
        LOGERR(klogInt, rc, "failed to initialize parent object");
    }
    if( rc != 0 ) {
        FastqLoaderFmt_Whack(fmt, NULL);
    } else {
        fmt->processing = processing;
        fmt->spots_bad_allowed = config->spots_bad_allowed;
        fmt->spots_bad_count = 0;
        *self = &fmt->dad;
    }
    return rc;
}
Example #2
0
rc_t SFFLoaderFmtMake(SRALoaderFmt** self, const SRALoaderConfig* config)
{
    rc_t rc = 0;
    SFFLoaderFmt* obj = NULL;
    const PlatformXML* platform;

    if( self == NULL || config == NULL ) {
        return RC(rcSRA, rcFormatter, rcConstructing, rcSelf, rcNull);
    }
    *self = NULL;
    if( (rc = Experiment_GetPlatform(config->experiment, &platform)) != 0 ) {
        return rc;
    }
    obj = calloc(1, sizeof(SFFLoaderFmt));
    if(obj == NULL) {
        return RC(rcSRA, rcFormatter, rcConstructing, rcMemory, rcExhausted);
    }
    if( (rc = SRALoaderFmtInit(&obj->dad, (const SRALoaderFmt_vt*)&vtSFFLoaderFmt)) != 0 ) {
        LOGERR(klogInt, rc, "failed to initialize parent object");
    } else {
        if( platform->id == SRA_PLATFORM_454 ) {
            if( (rc = SRAWriter454_Make(&obj->w454, config)) != 0 ) {
                LOGERR(klogInt, rc, "failed to initialize writer");
            }
        } else {
            if( (rc = SRAWriterIonTorrent_Make(&obj->wIonTorrent, config)) != 0 ) {
                LOGERR(klogInt, rc, "failed to initialize Ion Torrent writer");
            }
        }
    }
    if(rc == 0) {
        obj->skip_signal = (config->columnFilter & efltrSIGNAL) && !(config->columnFilter & efltrDEFAULT);
        *self = &obj->dad;
    } else {
        free(obj);
    }
    return rc;
}