def generate_spades_yaml(self, reads_data):
    left = []
    right = []
    single = []
    pacbio = []
    interlaced = []
    illumina_present = 0
    iontorrent_present = 0
    for read in reads_data:
        seq_tech = read['seq_tech']
        if (seq_tech == 'PacBio CLR'):
            pacbio.append(read['fwd_file'])
        elif (read['type'] == 'paired'):
            if (('rev_file' in read) and read['rev_file']):
                left.append(read['fwd_file'])
                right.append(read['rev_file'])
            else:
                interlaced.append(read['fwd_file'])
        elif (read['type'] == 'single'):
            single.append(read['fwd_file'])
        if (seq_tech == 'IonTorrent'):
            iontorrent_present = 1
        elif (seq_tech == 'Illumina'):
            illumina_present = 1
    if ((illumina_present == 1) and (iontorrent_present == 1)):
        raise ValueError(('Both IonTorrent and Illumina read libraries exist. ' + 'SPAdes can not assemble them together.'))
    yml = []
    yml_index_counter = 0
    other_reads_present_for_pacbio = 0
    if (left or interlaced):
        yml.append({'type': 'paired-end', 'orientation': 'fr'})
        if left:
            yml[yml_index_counter]['left reads'] = left
            yml[yml_index_counter]['right reads'] = right
        if interlaced:
            yml[yml_index_counter]['interlaced reads'] = interlaced
        yml_index_counter += 1
        other_reads_present_for_pacbio = 1
    if single:
        yml.append({'type': 'single'})
        yml[yml_index_counter]['single reads'] = single
        yml_index_counter += 1
        other_reads_present_for_pacbio = 1
    if pacbio:
        if (other_reads_present_for_pacbio == 1):
            yml.append({'type': 'pacbio'})
            yml[yml_index_counter]['single reads'] = pacbio
            yml_index_counter += 1
        else:
            raise ValueError(('Per SPAdes requirements : If doing PacBio CLR reads, you must ' + 'also supply at least one paired end or single end reads library'))
    yml_path = os.path.join(self.scratch, 'run.yaml')
    with open(yml_path, 'w') as yml_file:
        yaml.safe_dump(yml, yml_file)
    return (yml_path, iontorrent_present)
def generate_spades_yaml(self, reads_data):
    left = []
    right = []
    single = []
    pacbio = []
    interlaced = []
    illumina_present = 0
    iontorrent_present = 0
    for read in reads_data:
        seq_tech = read['seq_tech']
        if (seq_tech == 'PacBio CLR'):
            pacbio.append(read['fwd_file'])
        elif (read['type'] == 'paired'):
            if (('rev_file' in read) and read['rev_file']):
                left.append(read['fwd_file'])
                right.append(read['rev_file'])
            else:
                interlaced.append(read['fwd_file'])
        elif (read['type'] == 'single'):
            single.append(read['fwd_file'])
        if (seq_tech == 'IonTorrent'):
            iontorrent_present = 1
        elif (seq_tech == 'Illumina'):
            illumina_present = 1
    if ((illumina_present == 1) and (iontorrent_present == 1)):
        raise ValueError(('Both IonTorrent and Illumina read libraries exist. ' + 'SPAdes can not assemble them together.'))
    yml = []
    yml_index_counter = 0
    other_reads_present_for_pacbio = 0
    if (left or interlaced):
        yml.append({'type': 'paired-end', 'orientation': 'fr'})
        if left:
            yml[yml_index_counter]['left reads'] = left
            yml[yml_index_counter]['right reads'] = right
        if interlaced:
            yml[yml_index_counter]['interlaced reads'] = interlaced
        yml_index_counter += 1
        other_reads_present_for_pacbio = 1
    if single:
        yml.append({'type': 'single'})
        yml[yml_index_counter]['single reads'] = single
        yml_index_counter += 1
        other_reads_present_for_pacbio = 1
    if pacbio:
        if (other_reads_present_for_pacbio == 1):
            yml.append({'type': 'pacbio'})
            yml[yml_index_counter]['single reads'] = pacbio
            yml_index_counter += 1
        else:
            raise ValueError(('Per SPAdes requirements : If doing PacBio CLR reads, you must ' + 'also supply at least one paired end or single end reads library'))
    yml_path = os.path.join(self.scratch, 'run.yaml')
    with open(yml_path, 'w') as yml_file:
        yaml.safe_dump(yml, yml_file)
    return (yml_path, iontorrent_present)