Пример #1
0
def reannotate_trials():
    db = database.get_db()
    trials = list(db['trial'].find())

    # modify trials to be inserted in bulk later
    events.trial_insert(trials)

    # re-insert.
    for trial in trials:
        db['trial'].delete_one({'_id': trial['_id']})
        db['trial'].insert_one(trial)

    logging.info("DONE")
Пример #2
0
def reannotate_trials():

    # connect to the database.
    db = database.get_db()

    # get all trials.
    trials = list(db['trial'].find())

    # call hooks.
    events.trial_insert(trials)

    # re-insert.
    for trial in trials:
        db['trial'].delete_one({'_id': trial['_id']})
        db['trial'].insert_one(trial)
Пример #3
0
    def test_trial_normalization(self):

        db = get_db()
        db['normalize'].insert(MAPPING)

        # define test json
        with open(os.path.join(YAML_DIR, "00-001.yml")) as fin:
            test_json = yaml.load(fin)

        # do the mapping.
        UtilHooks.NormalizeHook.entry_insert("trial", [test_json])

        trial_insert([test_json])

        db['normalize'].drop()
Пример #4
0
    def test_trial_normalization(self):

        db = get_db()
        db['normalize'].insert(MAPPING)

        # define test json
        with open(os.path.join(YAML_DIR, "00-001.yml")) as fin:
            test_json = yaml.load(fin)

        # do the mapping.
        UtilHooks.NormalizeHook.entry_insert("trial", [test_json])

        trial_insert([test_json])

        db['normalize'].drop()
Пример #5
0
def reannotate_trials():

    # connect to the database.
    db = database.get_db()

    # get all trials.
    trials = list(db['trial'].find())

    # call hooks.
    events.trial_insert(trials)

    # re-insert.
    for trial in trials:
        db['trial'].delete_one({'_id': trial['_id']})
        db['trial'].insert_one(trial)
Пример #6
0
    def test_updatedt_with_curatedt(self):

        # set up
        today = dt.datetime.now().strftime('%B %d, %Y')
        old = 'October 27, 2016'
        on_trial['_genomic'] = {'hugo_symbol': [{'value': 'TEST'}]}
        on_trial['_clinical'] = {'disease_status': [{'value': ['TEST']}]}

        # set both dates to OLD
        on_trial['curated_on'] = old
        on_trial['last_updated'] = old
        assert on_trial['curated_on'] == old, self._debug(
            on_trial, 'curated_on')
        assert on_trial['last_updated'] == old, self._debug(
            on_trial, 'last_updated')

        # set "last_updated" to TODAY
        trial = set_updated(on_trial)
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(
            trial, 'last_updated')

        # check dates are preserved after trial_insert is called
        trial['protocol_no'] = '01-001'
        trial = trial_insert([trial])
        trial = trial[0]
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(
            trial, 'last_updated')

        # check the other way around
        on_trial['curated_on'] = old
        trial['last_updated'] = old
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == old, self._debug(trial, 'last_updated')

        trial = set_curated(on_trial)
        assert trial['curated_on'] == today, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(
            trial, 'last_updated')

        trial = trial_insert([trial])
        trial = trial[0]
        assert trial['curated_on'] == today, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(
            trial, 'last_updated')
Пример #7
0
    def test_trial_insert(self):

        # loop over each trial.
        executed_new_yaml = False
        for trial_name in os.listdir(YAML_DIR):

            # open the trial as json
            trial_path = os.path.join(YAML_DIR, trial_name)
            with open(trial_path, "rb") as fin:

                # load yaml
                data_json = yaml.load(fin.read())

                # normalize.
                UtilHooks.NormalizeHook.entry_insert('trial', [data_json])

                # insert it.
                trial_insert([data_json])

                # check these fields are present.
                assert '_summary' in data_json

            # trial 15-153 contains hormone receptor status and wildtype hugo symbol fields
            if trial_name == '00-002.yml':
                assert 'PIK3CA' in data_json['_summary']["genes"]
                assert 'wt PIK3CA' in data_json['_summary']["genes"]
                assert 'Invasive Breast Carcinoma ER+/HER2-' in data_json[
                    '_summary']['tumor_types']
                assert len(data_json['_summary']['tumor_types']) == 1
                assert set(data_json['_summary']['disease_status']) == {
                    'Metastatic', 'Advanced'
                }
                executed_new_yaml = True

            if trial_name == '00-001.yml':
                for diag in data_json['_summary']['tumor_types']:
                    assert diag[0] != '!'

        assert executed_new_yaml, 'Please add trial 00-002 to the tests/data/yaml directory so that' \
                                  'hormone receptor status and wildtype hugo symbol functionality can be' \
                                  'adequately tested.'
Пример #8
0
    def test_updatedt_with_curatedt(self):

        # set up
        today = dt.datetime.now().strftime('%B %d, %Y')
        old = 'October 27, 2016'
        on_trial['_genomic'] = {'hugo_symbol': [{'value': 'TEST'}]}
        on_trial['_clinical'] = {'disease_status': [{'value': ['TEST']}]}

        # set both dates to OLD
        on_trial['curated_on'] = old
        on_trial['last_updated'] = old
        assert on_trial['curated_on'] == old, self._debug(on_trial, 'curated_on')
        assert on_trial['last_updated'] == old, self._debug(on_trial, 'last_updated')

        # set "last_updated" to TODAY
        trial = set_updated(on_trial)
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(trial, 'last_updated')

        # check dates are preserved after trial_insert is called
        trial = trial_insert([trial])
        trial = trial[0]
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(trial, 'last_updated')

        # check the other way around
        on_trial['curated_on'] = old
        trial['last_updated'] = old
        assert trial['curated_on'] == old, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == old, self._debug(trial, 'last_updated')

        trial = set_curated(on_trial)
        assert trial['curated_on'] == today, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(trial, 'last_updated')

        trial = trial_insert([trial])
        trial = trial[0]
        assert trial['curated_on'] == today, self._debug(trial, 'curated_on')
        assert trial['last_updated'] == today, self._debug(trial, 'last_updated')
Пример #9
0
    def test_trial_insert(self):

        # loop over each trial.
        executed_new_yaml = False
        for trial_name in os.listdir(YAML_DIR):

            # open the trial as json
            trial_path = os.path.join(YAML_DIR, trial_name)
            with open(trial_path, "rb") as fin:

                # load yaml
                data_json = yaml.load(fin.read())

                # normalize.
                UtilHooks.NormalizeHook.entry_insert('trial', [data_json])

                # insert it.
                trial_insert([data_json])

                # check these fields are present.
                assert '_summary' in data_json

            # trial 15-153 contains hormone receptor status and wildtype hugo symbol fields
            if trial_name == '00-002.yml':
                assert 'PIK3CA' in data_json['_summary']["genes"]
                assert 'wt PIK3CA' in data_json['_summary']["genes"]
                assert 'Invasive Breast Carcinoma ER+/HER2-' in data_json['_summary']['tumor_types']
                assert len(data_json['_summary']['tumor_types']) == 1
                assert data_json['_summary']['disease_status'] == ['Metastatic', 'Advanced']
                executed_new_yaml = True

            if trial_name == '00-001.yml':
                for diag in data_json['_summary']['tumor_types']:
                    assert diag[0] != '!'

        assert executed_new_yaml, 'Please add trial 00-002 to the tests/data/yaml directory so that' \
                                  'hormone receptor status and wildtype hugo symbol functionality can be' \
                                  'adequately tested.'