Exemple #1
0
    def sync_score_row(legacy_row):
        legacy_score_code = legacy_row[2]
        legacy_scorer = legacy_row[3]
        experiment = get_experiment(legacy_row[0], tile_to_well(legacy_row[1]))
        score_code = get_score_code(legacy_score_code)
        scorer = get_user(legacy_scorer)

        timestamp = get_timestamp_from_ymd(legacy_row[4], legacy_row[5])
        if not timestamp:
            raise CommandError(
                'ERROR: score of experiment {}, well {} '
                'could not be converted to a proper datetime'
                .format(legacy_row[0], legacy_row[1]))

        new_score = ManualScore(
            experiment=experiment,
            score_code=score_code,
            scorer=scorer,
            timestamp=timestamp)

        return update_or_save_object(
            command, new_score, recorded_scores, fields_to_compare,
            alternate_pk={'experiment': new_score.experiment,
                          'score_code': new_score.score_code,
                          'scorer': new_score.scorer,
                          'timestamp': new_score.timestamp})
Exemple #2
0
    def sync_score_row(legacy_row):
        legacy_score_code = legacy_row[2]
        legacy_scorer = legacy_row[3]
        experiment = get_experiment(legacy_row[0], tile_to_well(legacy_row[1]))
        score_code = get_score_code(legacy_score_code)
        scorer = get_user(legacy_scorer)

        timestamp = get_timestamp_from_ymd(legacy_row[4], legacy_row[5])
        if not timestamp:
            raise CommandError(
                'ERROR: score of experiment {}, well {} '
                'could not be converted to a proper datetime'.format(
                    legacy_row[0], legacy_row[1]))

        new_score = ManualScore(experiment=experiment,
                                score_code=score_code,
                                scorer=scorer,
                                timestamp=timestamp)

        return update_or_save_object(command,
                                     new_score,
                                     recorded_scores,
                                     fields_to_compare,
                                     alternate_pk={
                                         'experiment': new_score.experiment,
                                         'score_code': new_score.score_code,
                                         'scorer': new_score.scorer,
                                         'timestamp': new_score.timestamp
                                     })
Exemple #3
0
    def sync_score_row(legacy_row):
        legacy_score_code = legacy_row[2]
        legacy_scorer = legacy_row[3]
        gene = legacy_row[9]
        screen = legacy_row[10]

        # Skip some scores entirely (see criteria above)
        skip_entirely = ('alejandro', 'katy')
        skip_ENH = ('eliana', 'lara')

        if ((legacy_scorer == 'Julie' and legacy_score_code != -2)
                or (legacy_scorer in skip_entirely)
                or (screen == 'ENH' and legacy_scorer in skip_ENH)):
            command.stderr.write(
                'FYI: Skipping a {} {} score of {} by {}\n'.format(
                    gene, screen, legacy_score_code, legacy_scorer))

            return True

        # Convert some scorers to hueyling (see criteria above)
        if legacy_scorer == 'Julie' or legacy_scorer == 'expPeople':
            command.stderr.write(
                'FYI: Converting a {} score by {} to hueyling\n'.format(
                    legacy_score_code, legacy_scorer))

            legacy_scorer = 'hueyling'

        # Convert some score codes (see criteria above)
        if legacy_score_code == -6:
            command.stderr.write('FYI: Converting score from -6 to -7\n')
            legacy_score_code = -7

        # Following raise exceptions if improperly formatted or not found
        experiment = get_experiment(legacy_row[0], tile_to_well(legacy_row[1]))
        score_code = get_score_code(legacy_score_code)
        scorer = get_user(legacy_scorer)

        timestamp = get_timestamp(legacy_row[5], legacy_row[6], legacy_row[7],
                                  legacy_row[8], legacy_row[4])
        if not timestamp:
            raise CommandError(
                'ERROR: score of {} could  not be converted to a proper '
                'datetime'.format(experiment))

        new_score = ManualScore(experiment=experiment,
                                score_code=score_code,
                                scorer=scorer,
                                timestamp=timestamp)

        return update_or_save_object(command,
                                     new_score,
                                     recorded_scores,
                                     fields_to_compare,
                                     alternate_pk={
                                         'experiment': new_score.experiment,
                                         'score_code': new_score.score_code,
                                         'scorer': new_score.scorer,
                                         'timestamp': new_score.timestamp
                                     })
Exemple #4
0
    def sync_score_row(legacy_row):
        legacy_score_code = legacy_row[2]
        legacy_scorer = legacy_row[3]
        gene = legacy_row[9]
        screen = legacy_row[10]

        # Skip some scores entirely (see criteria above)
        skip_entirely = ('alejandro', 'katy')
        skip_ENH = ('eliana', 'lara')

        if ((legacy_scorer == 'Julie' and legacy_score_code != -2) or
                (legacy_scorer in skip_entirely) or
                (screen == 'ENH' and legacy_scorer in skip_ENH)):
            command.stderr.write(
                'FYI: Skipping a {} {} score of {} by {}\n'
                .format(gene, screen, legacy_score_code, legacy_scorer))

            return True

        # Convert some scorers to hueyling (see criteria above)
        if legacy_scorer == 'Julie' or legacy_scorer == 'expPeople':
            command.stderr.write(
                'FYI: Converting a {} score by {} to hueyling\n'
                .format(legacy_score_code, legacy_scorer))

            legacy_scorer = 'hueyling'

        # Convert some score codes (see criteria above)
        if legacy_score_code == -6:
            command.stderr.write('FYI: Converting score from -6 to -7\n')
            legacy_score_code = -7

        # Following raise exceptions if improperly formatted or not found
        experiment = get_experiment(legacy_row[0], tile_to_well(legacy_row[1]))
        score_code = get_score_code(legacy_score_code)
        scorer = get_user(legacy_scorer)

        timestamp = get_timestamp(legacy_row[5], legacy_row[6], legacy_row[7],
                                  legacy_row[8], legacy_row[4])
        if not timestamp:
            raise CommandError(
                'ERROR: score of {} could  not be converted to a proper '
                'datetime'.format(experiment))

        new_score = ManualScore(
            experiment=experiment,
            score_code=score_code,
            scorer=scorer,
            timestamp=timestamp)

        return update_or_save_object(
            command, new_score, recorded_scores, fields_to_compare,
            alternate_pk={'experiment': new_score.experiment,
                          'score_code': new_score.score_code,
                          'scorer': new_score.scorer,
                          'timestamp': new_score.timestamp})
Exemple #5
0
    def sync_score_row(legacy_row):
        # Build the object using the minimimum fields
        count_adult = legacy_row[8]
        count_larva = legacy_row[9]
        if count_adult == -1:
            count_adult = None
        if count_larva == -1:
            count_larva = None

        machine_call = legacy_row[15]
        if machine_call:
            selected_for_scoring = True
        else:
            selected_for_scoring = False

        new_score = DevstarScore(
            experiment=get_experiment(legacy_row[0], legacy_row[1]),
            area_adult=legacy_row[5],
            area_larva=legacy_row[6],
            area_embryo=legacy_row[7],
            count_adult=count_adult,
            count_larva=count_larva,
            is_bacteria_present=legacy_row[16],
            selected_for_scoring=selected_for_scoring,
            gi_score_larva_per_adult=legacy_row[17],
            gi_score_survival=legacy_row[18]
        )

        # Clean the object to populate the fields derived from other fields
        new_score.clean()

        ###############
        # SANITY CHECKS
        ###############

        errors = []

        new_allele = new_score.experiment.worm_strain.allele
        if (new_allele != legacy_row[2]):
            # Deal with case of legacy database using zc310 instead of zu310
            if (legacy_row[2] == 'zc310' and
                    new_allele == 'zu310'):
                pass

            # Deal with some case sensitivity issues in legacy database
            # (e.g. see experiment 32405, where the allele is capitalized).
            # Can't do lower() in all cases because "N2" should always be
            # capitalized.
            elif new_allele == legacy_row[2].lower():
                pass

            else:
                errors.append('allele mismatch')

        # Deal with case of some experiments having the wrong RNAiPlateID
        # in the legacy database's RawDataWithScore table. This field is
        # redundant with the RawData table, and RawData is more trustworthy;
        # however it is still worthwhile to perform this check in order
        # to find the mismatches, and to confirm manually that each one
        # makes sense.
        new_lp = new_score.experiment.library_stock.plate_id
        legacy_lp = legacy_row[4].replace('_', '-').replace('zc310', 'zu310')
        if (legacy_lp != new_lp and
                new_score.experiment.plate_id not in (461, 8345) and
                ('vidal-' not in new_lp or
                    legacy_lp != new_lp.split('vidal-')[1])):
            errors.append('RNAi plate mismatch: {} {}')

        if new_score.count_embryo != legacy_row[10]:
            errors.append('embryo count mismatch')

        if (new_score.embryo_per_adult and legacy_row[8] and
                legacy_row[8] != -1 and
                int(new_score.embryo_per_adult) != legacy_row[11]):
            errors.append('embryo per adult mismatch')

        if (new_score.larva_per_adult and legacy_row[9] and
                legacy_row[9] != -1 and
                int(new_score.larva_per_adult) != legacy_row[12]):
            errors.append('larva per adult mismatch')

        if (new_score.survival and not compare_floats_for_equality(
                new_score.survival, legacy_row[13]) and
                legacy_row[13] != 0):
            errors.append('invalid survival')

        if (new_score.lethality and not compare_floats_for_equality(
                new_score.lethality, legacy_row[14]) and
                legacy_row[13] != 0):
            errors.append('invalid lethality')

        if errors:
            raise CommandError(
                'DevstarScore for {}:{} had these errors: {}'
                .format(legacy_row[0], legacy_row[1], errors))

        return update_or_save_object(
            command, new_score, recorded_scores, fields_to_compare,
            alternate_pk={'experiment': new_score.experiment})
Exemple #6
0
    def sync_score_row(legacy_row):
        # Build the object using the minimimum fields
        count_adult = legacy_row[8]
        count_larva = legacy_row[9]
        if count_adult == -1:
            count_adult = None
        if count_larva == -1:
            count_larva = None

        machine_call = legacy_row[15]
        if machine_call:
            selected_for_scoring = True
        else:
            selected_for_scoring = False

        new_score = DevstarScore(experiment=get_experiment(
            legacy_row[0], legacy_row[1]),
                                 area_adult=legacy_row[5],
                                 area_larva=legacy_row[6],
                                 area_embryo=legacy_row[7],
                                 count_adult=count_adult,
                                 count_larva=count_larva,
                                 is_bacteria_present=legacy_row[16],
                                 selected_for_scoring=selected_for_scoring,
                                 gi_score_larva_per_adult=legacy_row[17],
                                 gi_score_survival=legacy_row[18])

        # Clean the object to populate the fields derived from other fields
        new_score.clean()

        ###############
        # SANITY CHECKS
        ###############

        errors = []

        new_allele = new_score.experiment.worm_strain.allele
        if (new_allele != legacy_row[2]):
            # Deal with case of legacy database using zc310 instead of zu310
            if (legacy_row[2] == 'zc310' and new_allele == 'zu310'):
                pass

            # Deal with some case sensitivity issues in legacy database
            # (e.g. see experiment 32405, where the allele is capitalized).
            # Can't do lower() in all cases because "N2" should always be
            # capitalized.
            elif new_allele == legacy_row[2].lower():
                pass

            else:
                errors.append('allele mismatch')

        # Deal with case of some experiments having the wrong RNAiPlateID
        # in the legacy database's RawDataWithScore table. This field is
        # redundant with the RawData table, and RawData is more trustworthy;
        # however it is still worthwhile to perform this check in order
        # to find the mismatches, and to confirm manually that each one
        # makes sense.
        new_lp = new_score.experiment.library_stock.plate_id
        legacy_lp = legacy_row[4].replace('_', '-').replace('zc310', 'zu310')
        if (legacy_lp != new_lp
                and new_score.experiment.plate_id not in (461, 8345)
                and ('vidal-' not in new_lp
                     or legacy_lp != new_lp.split('vidal-')[1])):
            errors.append('RNAi plate mismatch: {} {}')

        if new_score.count_embryo != legacy_row[10]:
            errors.append('embryo count mismatch')

        if (new_score.embryo_per_adult and legacy_row[8]
                and legacy_row[8] != -1
                and int(new_score.embryo_per_adult) != legacy_row[11]):
            errors.append('embryo per adult mismatch')

        if (new_score.larva_per_adult and legacy_row[9] and legacy_row[9] != -1
                and int(new_score.larva_per_adult) != legacy_row[12]):
            errors.append('larva per adult mismatch')

        if (new_score.survival and not compare_floats_for_equality(
                new_score.survival, legacy_row[13]) and legacy_row[13] != 0):
            errors.append('invalid survival')

        if (new_score.lethality and not compare_floats_for_equality(
                new_score.lethality, legacy_row[14]) and legacy_row[13] != 0):
            errors.append('invalid lethality')

        if errors:
            raise CommandError(
                'DevstarScore for {}:{} had these errors: {}'.format(
                    legacy_row[0], legacy_row[1], errors))

        return update_or_save_object(
            command,
            new_score,
            recorded_scores,
            fields_to_compare,
            alternate_pk={'experiment': new_score.experiment})