This module will accept a dict object holding the 3 input prefixes and the patient id and will
    attempt to store the fastqs to the jobstore.  The input files must satisfy the following
    1. File extensions can only be fastq or fq (.gz is also allowed)
    2. Forward and reverse reads MUST be in the same folder with the same prefix
    3. The files must be on the form
                    <prefix_for_file>1.<fastq/fq>[.gz]
                    <prefix_for_file>2.<fastq/fq>[.gz]
    The input  dict is:
    tumor_dna: prefix_to_tumor_dna
    tumor_rna: prefix_to_tumor_rna
    normal_dna: prefix_to_normal_dna
    patient_id: patient ID

    The input dict is updated to
    tumor_dna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    tumor_rna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    normal_dna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    patient_id: patient ID
    gzipped: True/False

    This module corresponds to node 1 in the tree

def prepare_samples(job, fastqs, univ_options):
    """
    This module will accept a dict object holding the 3 input prefixes and the patient id and will
    attempt to store the fastqs to the jobstore.  The input files must satisfy the following
    1. File extensions can only be fastq or fq (.gz is also allowed)
    2. Forward and reverse reads MUST be in the same folder with the same prefix
    3. The files must be on the form
                    <prefix_for_file>1.<fastq/fq>[.gz]
                    <prefix_for_file>2.<fastq/fq>[.gz]
    The input  dict is:
    tumor_dna: prefix_to_tumor_dna
    tumor_rna: prefix_to_tumor_rna
    normal_dna: prefix_to_normal_dna
    patient_id: patient ID

    The input dict is updated to
    tumor_dna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    tumor_rna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    normal_dna: [jobStoreID_for_fastq1, jobStoreID_for_fastq2]
    patient_id: patient ID
    gzipped: True/False

    This module corresponds to node 1 in the tree
    """
    job.fileStore.logToMaster('Downloading Inputs for %s' % univ_options['patient'])
    allowed_samples = {'tumor_dna_fastq_prefix', 'tumor_rna_fastq_prefix',
                       'normal_dna_fastq_prefix'}
    if set(fastqs.keys()).difference(allowed_samples) != {'patient_id'}:
        raise ParameterError('Sample with the following parameters has an error:\n' +
                             '\n'.join(fastqs.values()))
    # For each sample type, check if the prefix is an S3 link or a regular file
    # Download S3 files.
    for sample_type in ['tumor_dna', 'tumor_rna', 'normal_dna']:
        prefix = fastqs[''.join([sample_type, '_fastq_prefix'])]
        # if the file was an xml, process it before moving further.
        if prefix.endswith('.xml'):
            prefix = get_file_from_cghub(job, fastqs[''.join([sample_type, '_fastq_prefix'])],
                                         univ_options['cghub_key'], univ_options,
                                         write_to_jobstore=False)
        # If gzipped, remember that
        if prefix.endswith('.gz'):
            prefix = os.path.splitext(prefix)[0]
            fastqs['gzipped'] = True
        else:
            fastqs['gzipped'] = False
        # Is the file .fastq or .fq
        if prefix.endswith(('.fastq', '.fq')):
            prefix, extn = os.path.splitext(prefix)
            # If the file was gzipped, add that to the extension
            if fastqs['gzipped']:
                extn = ''.join([extn, '.gz'])
        else:
            raise ParameterError('Are the inputs for patient (%s) fastq/fq?' % fastqs['patient_id'])
        # Handle the R1/R2 identifiers in the prefix.  That is added by the program.
        assert prefix.endswith('1'), 'Prefix didn\'t end with 1.<fastq/fq>[.gz]: (%s.%s)' % (prefix,
                                                                                             extn)
        prefix = prefix[:-1]
        # If it is a weblink, it HAS to be from S3
        if prefix.startswith('https://s3') or prefix.startswith('S3://'):
            fastqs[sample_type] = [
                get_file_from_s3(job, ''.join([prefix, '1', extn]), univ_options['sse_key'],
                                 per_file_encryption=univ_options['sse_key_is_master']),
                get_file_from_s3(job, ''.join([prefix, '2', extn]), univ_options['sse_key'],
                                 per_file_encryption=univ_options['sse_key_is_master'])]
        else:
            # Relies heavily on the assumption that the pair will be in the same
            # folder
            assert os.path.exists(''.join([prefix, '1', extn])), 'Bogus input: %s' % ''.join(
                    [prefix, '1', extn])
            # Python lists maintain order hence the values are always guaranteed to be
            # [fastq1, fastq2]
            fastqs[sample_type] = [
                job.fileStore.writeGlobalFile(''.join([prefix, '1', extn])),
                job.fileStore.writeGlobalFile(''.join([prefix, '2', extn]))]
    [fastqs.pop(x) for x in allowed_samples]
    return fastqs