Ejemplo n.º 1
0
def write_bcl2fastq_samplesheet(samplesheet, samplesheet_path, conf):
    try:

        # Write CSV samplesheet file in BCL2FASTQ2 format
        writer = SampleSheetCSVWriter(samplesheet_path)
        writer.setVersion(2)
        writer.writer(samplesheet)

    except AozanException, exp:
        print StringUtils.stackTraceToString(exp)

        error("Error while writing Bcl2fastq samplesheet: " + samplesheet_path, exp.getMessage(), conf)
        return False
Ejemplo n.º 2
0
def update_samplesheet(samplesheet, run_id, lane_count, conf):
    common.log("INFO", "Flowcell lane count: " + str(lane_count), conf)

    try:

        # Replace index sequence shortcuts by sequences
        SampleSheetUtils.replaceIndexShortcutsBySequences(samplesheet, load_index_sequences(conf))

        # Set the lane field if does not set
        SampleSheetUtils.duplicateSamplesIfLaneFieldNotSet(samplesheet, lane_count)

    except AozanException, exp:
        print StringUtils.stackTraceToString(exp)

        error("Error while updating samplesheet for run " + run_id, exp.getMessage(), conf)
        return False
Ejemplo n.º 3
0
def load_samplesheet(run_id, input_run_data_path, samplesheet_filename, conf):
    """ Load the samplesheet.

    Arguments:
        run id: The run id
        input_run_data_path: The input run data path
        samplesheet_filename: samplesheet filename
        conf: configuration dictionary

    Return:
        a Samplesheet object and the original path of the samplesheet
    """

    run_info_path = input_run_data_path + '/RunInfo.xml'

    if not os.path.isfile(run_info_path):
        error("no RunInfo.xml file found for run " + run_id,
              "No RunInfo.xml file found for run " + run_id + ': ' + run_info_path + '.\n', conf)
        return None, None

    run_info = RunInfo.parse(run_info_path)
    flow_cell_id = run_info.getFlowCell()

    common.log("INFO", "Flowcell id: " + flow_cell_id, conf)
    common.log("INFO", "Samplesheet format: " + str(conf[BCL2FASTQ_SAMPLESHEET_FORMAT_KEY]), conf)

    try:
        if common.is_conf_value_defined(BCL2FASTQ_SAMPLESHEET_FORMAT_KEY, 'xls', conf):
            return load_samplesheet_using_extension(conf,samplesheet_filename,'xls',input_run_data_path,run_id)

        elif common.is_conf_value_defined(BCL2FASTQ_SAMPLESHEET_FORMAT_KEY, 'csv', conf):
            return load_samplesheet_using_extension(conf,samplesheet_filename,'csv',input_run_data_path,run_id)

        elif common.is_conf_value_defined(BCL2FASTQ_SAMPLESHEET_FORMAT_KEY, 'xlsx', conf):
            return load_samplesheet_using_extension(conf,samplesheet_filename,'xlsx',input_run_data_path,run_id)

        elif common.is_conf_value_defined(BCL2FASTQ_SAMPLESHEET_FORMAT_KEY, 'command', conf):
            action_error_msg = 'Error while creating Bcl2fastq CSV samplesheet file'
            if not common.is_conf_key_exists(BCL2FASTQ_SAMPLESHEET_GENERATOR_COMMAND_KEY, conf):
                error(action_error_msg + ' for run ' + run_id, action_error_msg + ' the command is empty.', conf)
                return None, None

            input_samplesheet_generated_path = conf[TMP_PATH_KEY] + '/' + samplesheet_filename + 'generated.csv'

            cmd = conf[
                      BCL2FASTQ_SAMPLESHEET_GENERATOR_COMMAND_KEY] + ' ' + run_id + ' ' + quote(input_samplesheet_generated_path)
            common.log("INFO", "exec: " + cmd, conf)
            if os.system(cmd) != 0:
                error(action_error_msg + ' for run ' + run_id,
                      action_error_msg + '.\nCommand line:\n' + cmd, conf)

            if not os.path.exists(input_samplesheet_generated_path):
                error(action_error_msg + ' for run ' + run_id,
                      action_error_msg + ', the external command did not create Bcl2fastq CSV file:\n' + cmd, conf)
                return None, None

            # Load CSV samplesheet file
            samplesheet = SampleSheetCSVReader(input_samplesheet_generated_path).read()

            # Remove generated samplesheet
            os.unlink(input_samplesheet_generated_path)

            return samplesheet, None

        else:
            error('Error while creating Bcl2fastq CSV samplesheet file for run ' + run_id,
                  'No method to get Bcl2fastq samplesheet file has been defined. Please, set the ' +
                  '"bcl2fastq.samplesheet.format" property.\n',
                  conf)
            return None, None

    except AozanException, exp:
        print StringUtils.stackTraceToString(exp)

        error("Error reading samplesheet: " + samplesheet_filename, exp.getMessage(), conf)
        return None, None
Ejemplo n.º 4
0
            return samplesheet, None

        else:
            error('Error while creating Bcl2fastq CSV samplesheet file for run ' + run_id,
                  'No method to get Bcl2fastq samplesheet file has been defined. Please, set the ' +
                  '"bcl2fastq.samplesheet.format" property.\n',
                  conf)
            return None, None

    except AozanException, exp:
        print StringUtils.stackTraceToString(exp)

        error("Error reading samplesheet: " + samplesheet_filename, exp.getMessage(), conf)
        return None, None
    except Exception, exp:
        print StringUtils.stackTraceToString(exp)

        error("Error reading samplesheet: " + samplesheet_filename, exp.getMessage(), conf)
        return None, None

    return None, None


def update_samplesheet(samplesheet, run_id, lane_count, conf):
    common.log("INFO", "Flowcell lane count: " + str(lane_count), conf)

    try:

        # Replace index sequence shortcuts by sequences
        SampleSheetUtils.replaceIndexShortcutsBySequences(samplesheet, load_index_sequences(conf))