Пример #1
0
    def sync_experiment_row(legacy_row):
        experiment_plate_id = legacy_row[0]
        worm_strain = get_worm_strain(legacy_row[1], legacy_row[2])
        legacy_library_plate_name = legacy_row[3]
        temperature = legacy_row[4]
        date = legacy_row[5]
        is_junk = legacy_row[6]
        comment = legacy_row[7]

        all_match = True

        if experiment_plate_id < 40000:
            screen_stage = 1
        else:
            screen_stage = 2

        new_plate = ExperimentPlate(
            id=experiment_plate_id,
            screen_stage=screen_stage,
            temperature=temperature,
            date=date,
            comment=comment)

        all_match &= update_or_save_object(
            command, new_plate, recorded_plates, plate_fields_to_compare)

        experiment_plate = get_experiment_plate(experiment_plate_id)

        for well in get_well_list():
            new_well = Experiment(
                id=generate_experiment_id(experiment_plate_id, well),
                plate=experiment_plate, well=well,
                worm_strain=worm_strain,
                library_stock=get_library_stock(
                    legacy_library_plate_name, well),
                is_junk=is_junk)

            all_match &= update_or_save_object(
                command, new_well, recorded_wells,
                well_fields_to_compare)

        return all_match
Пример #2
0
    def sync_experiment_row(legacy_row):
        experiment_plate_id = legacy_row[0]
        worm_strain = get_worm_strain(legacy_row[1], legacy_row[2])
        legacy_library_plate_name = legacy_row[3]
        temperature = legacy_row[4]
        date = legacy_row[5]
        is_junk = legacy_row[6]
        comment = legacy_row[7]

        all_match = True

        if experiment_plate_id < 40000:
            screen_stage = 1
        else:
            screen_stage = 2

        new_plate = ExperimentPlate(id=experiment_plate_id,
                                    screen_stage=screen_stage,
                                    temperature=temperature,
                                    date=date,
                                    comment=comment)

        all_match &= update_or_save_object(command, new_plate, recorded_plates,
                                           plate_fields_to_compare)

        experiment_plate = get_experiment_plate(experiment_plate_id)

        for well in get_well_list():
            new_well = Experiment(
                id=generate_experiment_id(experiment_plate_id, well),
                plate=experiment_plate,
                well=well,
                worm_strain=worm_strain,
                library_stock=get_library_stock(legacy_library_plate_name,
                                                well),
                is_junk=is_junk)

            all_match &= update_or_save_object(command, new_well,
                                               recorded_wells,
                                               well_fields_to_compare)

        return all_match
Пример #3
0
    def sync_primary_row(legacy_row):
        plate_name = legacy_row[0]
        well = get_three_character_well(legacy_row[1])
        clone_name = legacy_row[2]
        parent_plate_name = legacy_row[4]

        if re.match('sjj', clone_name):
            parent_chromosome = legacy_row[3]
            parent_plate_name = generate_ahringer_384_plate_name(
                parent_chromosome, parent_plate_name)
        parent_well_improper = legacy_row[5]
        if re.match('mv', clone_name):
            clone_name = generate_vidal_clone_name(parent_plate_name,
                                                   parent_well_improper)

        intended_clone = get_clone(clone_name)

        if re.match('L4440', clone_name):
            parent_stock = None

        else:
            parent_well_proper = get_three_character_well(parent_well_improper)
            parent_stock = get_library_stock(parent_plate_name,
                                             parent_well_proper)

            # Confirm that this intended clone matches parent's clone
            if parent_stock.intended_clone != intended_clone:
                raise CommandError('Clone {} does not match parent\n'
                                   .format(clone_name))

        new_well = LibraryStock(
            id=generate_library_stock_name(plate_name, well),
            plate=get_library_plate(plate_name), well=well,
            parent_stock=parent_stock,
            intended_clone=intended_clone)

        return update_or_save_object(command, new_well, recorded_wells,
                                     fields_to_compare)
Пример #4
0
    def sync_eliana_row(legacy_row):
        plate_name = legacy_row[0]
        well = get_three_character_well(legacy_row[1])

        if legacy_row[2]:
            try:
                parent_stock = get_library_stock(legacy_row[2], legacy_row[3])
                intended_clone = parent_stock.intended_clone
            except ObjectDoesNotExist:
                parent_stock = None
                intended_clone = None

        else:
            parent_stock = None
            intended_clone = None

        new_well = LibraryStock(
            id=generate_library_stock_name(plate_name, well),
            plate=get_library_plate(plate_name), well=well,
            parent_stock=parent_stock,
            intended_clone=intended_clone)

        return update_or_save_object(command, new_well, recorded_wells,
                                     fields_to_compare)
Пример #5
0
    def handle(self, **options):
        require_db_write_acknowledgement()

        tracking_numbers = options['tracking_numbers']
        genewiz_root = options['genewiz_output_root']

        if not os.path.isdir(genewiz_root):
            raise CommandError('genewiz_root directory not found')

        # legacy_db = MySQLdb.connect(host=LEGACY_DATABASE['HOST'],
        legacy_db = mysql.connector.connect(host=LEGACY_DATABASE['HOST'],
                                            user=LEGACY_DATABASE['USER'],
                                            passwd=LEGACY_DATABASE['PASSWORD'],
                                            db=LEGACY_DATABASE['NAME'])

        cursor = legacy_db.cursor()

        ####################################################
        # FIRST STAGE: Create a dictionary of which
        #   sequences correspond to which library stocks
        #
        # This information is stored in the legacy database.
        ####################################################
        seq_to_source = {}

        cursor.execute(
            'SELECT SeqPlateID, Seq96Well, RNAiPlateID, 96well, oriClone '
            'FROM SeqPlate WHERE SeqPlateID <= 55')

        for row in cursor.fetchall():
            seq_plate_number, seq_well = row[0:2]
            seq_plate = 'JL' + str(seq_plate_number)

            try:
                library_stock = get_library_stock(row[2], row[3])

            except ObjectDoesNotExist:
                raise CommandError('LibraryStock not found for {} {}\n'.format(
                    row[0], row[1]))

            # Sanity check that clone matches
            legacy_clone = row[4]
            if legacy_clone:
                clone = library_stock.intended_clone
                if (not clone or
                    (legacy_clone != clone.id and 'GHR' not in clone.id)):
                    self.stderr.write(
                        'WARNING: Legacy clone mismatch for {}: {} {}\n'.
                        format(library_stock, clone, legacy_clone))

            seq_to_source[seq_plate + '_' + seq_well] = library_stock

        ####################################
        # SECOND STAGE: Add raw genewiz data
        #   (sequences and quality scores)
        ####################################

        reader = csv.DictReader(tracking_numbers)

        for row in reader:
            tracking_number = row['tracking_number'].strip()
            order_date = row['order_date'].strip()
            process_tracking_number(tracking_number, order_date, genewiz_root,
                                    seq_to_source)
Пример #6
0
    def sync_secondary_row(legacy_row):
        plate_name = legacy_row[0]
        well = get_three_character_well(legacy_row[1])
        clone_name = legacy_row[2]

        definite_parent_plate_name = legacy_row[3]
        definite_parent_well = legacy_row[4]
        if definite_parent_well:
            definite_parent_well = get_three_character_well(
                definite_parent_well)

        likely_parent_plate_name = legacy_row[5]
        likely_parent_well = legacy_row[6]
        if likely_parent_well:
            likely_parent_well = get_three_character_well(likely_parent_well)

        likely_parent_clone_name = legacy_row[7]

        if (definite_parent_plate_name and likely_parent_plate_name and
                definite_parent_plate_name != likely_parent_plate_name):
            raise CommandError(
                'ERROR: definite and likely parent plates disagree '
                'for {} {}\n'.format(plate_name, well))

        if (definite_parent_well and likely_parent_well and
                definite_parent_well != likely_parent_well):
            raise CommandError(
                'ERROR: definite and likely parent wells disagree '
                'for {} {}\n'.format(plate_name, well))

        try:
            if definite_parent_plate_name and definite_parent_well:
                parent_stock = get_library_stock(definite_parent_plate_name,
                                                 definite_parent_well)

            else:
                parent_stock = get_library_stock(likely_parent_plate_name,
                                                 likely_parent_well)

            intended_clone = parent_stock.intended_clone

        except ObjectDoesNotExist:
            command.stderr.write(
                'WARNING for LibraryStock {} {}: parent not '
                'found in LibraryStock\n'.format(plate_name, well))

            parent_stock = None
            intended_clone = None

        if clone_name and (clone_name != likely_parent_clone_name):
            command.stderr.write(
                'WARNING for LibraryStock {} {}: clone recorded '
                'in CherryPickRNAiPlate is inconsistent with '
                'CherryPickTemplate source/destination records\n'
                .format(plate_name, well))

        if re.match('sjj', clone_name):
            try:
                recorded_clone = get_clone(clone_name)
                if recorded_clone != intended_clone:
                    command.stderr.write(
                        'WARNING for LibraryStock {} {}: clone recorded '
                        'in CherryPickRNAiPlate does not match its '
                        'parent\'s clone\n'.format(plate_name, well))

            except ObjectDoesNotExist:
                command.stderr.write(
                    'WARNING for LibraryStock {} {}: clone recorded in '
                    'CherryPickRNAiPlate not found at all in RNAiPlate\n'
                    .format(plate_name, well))

        new_well = LibraryStock(
            id=generate_library_stock_name(plate_name, well),
            plate=get_library_plate(plate_name), well=well,
            parent_stock=parent_stock,
            intended_clone=intended_clone)

        return update_or_save_object(command, new_well, recorded_wells,
                                     fields_to_compare)
Пример #7
0
    def handle(self, **options):
        require_db_write_acknowledgement()

        tracking_numbers = options['tracking_numbers']
        genewiz_root = options['genewiz_output_root']

        if not os.path.isdir(genewiz_root):
            raise CommandError('genewiz_root directory not found')

        legacy_db = MySQLdb.connect(host=LEGACY_DATABASE['HOST'],
                                    user=LEGACY_DATABASE['USER'],
                                    passwd=LEGACY_DATABASE['PASSWORD'],
                                    db=LEGACY_DATABASE['NAME'])

        cursor = legacy_db.cursor()

        ####################################################
        # FIRST STAGE: Create a dictionary of which
        #   sequences correspond to which library stocks
        #
        # This information is stored in the legacy database.
        ####################################################
        seq_to_source = {}

        cursor.execute(
            'SELECT SeqPlateID, Seq96Well, RNAiPlateID, 96well, oriClone '
            'FROM SeqPlate WHERE SeqPlateID <= 55')

        for row in cursor.fetchall():
            seq_plate_number, seq_well = row[0:2]
            seq_plate = 'JL' + str(seq_plate_number)

            try:
                library_stock = get_library_stock(row[2], row[3])

            except ObjectDoesNotExist:
                raise CommandError('LibraryStock not found for {} {}\n'
                                   .format(row[0], row[1]))

            # Sanity check that clone matches
            legacy_clone = row[4]
            if legacy_clone:
                clone = library_stock.intended_clone
                if (not clone or (legacy_clone != clone.id and
                                  'GHR' not in clone.id)):
                    self.stderr.write(
                        'WARNING: Legacy clone mismatch for {}: {} {}\n'
                        .format(library_stock, clone, legacy_clone))

            seq_to_source[seq_plate + '_' + seq_well] = library_stock

        ####################################
        # SECOND STAGE: Add raw genewiz data
        #   (sequences and quality scores)
        ####################################

        reader = csv.DictReader(tracking_numbers)

        for row in reader:
            tracking_number = row['tracking_number'].strip()
            order_date = row['order_date'].strip()
            process_tracking_number(tracking_number, order_date,
                                    genewiz_root, seq_to_source)