Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/osmoai/publications
15 September 2023, 19:03:31 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision 1ed5899d22f225b2e03d53dd23d109d8c7b87dfc authored by Rick Gerkin on 25 April 2023, 01:00:55 UTC, committed by GitHub on 25 April 2023, 01:00:55 UTC
Create README.md
1 parent 1643707
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • 1ed5899d22f225b2e03d53dd23d109d8c7b87dfc
    No releases to show
  • 734cbcc
  • /
  • lee_et_al_2023
  • /
  • src
  • /
  • data_loaders.py
Raw File Download Save again
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:1ed5899d22f225b2e03d53dd23d109d8c7b87dfc
origin badgedirectory badge
swh:1:dir:9b439c8800f1cd38f7e33461013419d71e619299
origin badgecontent badge
swh:1:cnt:4dfc8cc18c3d3be559883bad7ebbbc7b707f4ba1
origin badgesnapshot badge
swh:1:snp:c43d033ddac10413c69edd9339aaca62b46b295e

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 1ed5899d22f225b2e03d53dd23d109d8c7b87dfc authored by Rick Gerkin on 25 April 2023, 01:00:55 UTC
Create README.md
Tip revision: 1ed5899
data_loaders.py
import numpy as np
import pandas as pd
from typing import Iterable, Union

from lee_et_al_2023.src import base


def load_gnn_rf_predictions(mol_codes):
    """Load GNN and RF ratings for a set of RedJade codes.
    
    Args:
        mol_codes: Molecules for which to retrieve predictions
    """
    files = {
        'RF': base.DATA_PATH / 'Data S4.csv',
        'GNN': base.DATA_PATH / 'Data S5.csv',
    }
    return {
        model_name: pd.read_csv(prediction_file
            ).set_index('RedJade Code'
            ).loc[mol_codes]
        for model_name, prediction_file in files.items()
    }


def load_extended_predictions(mol_codes):
    files = {
        'GNN': base.DATA_PATH / 'Data S5.csv',
        'RF_cFP': base.DATA_PATH / 'Data S4.csv',
        'RF_Mordred': base.DATA_PATH / 'standardized_rf_Mordred.csv',
        'KNN_cFP': base.DATA_PATH / 'standardized_knn_cFP.csv',
        'KNN_Mordred': base.DATA_PATH / 'standardized_knn_Mordred.csv',
    }
    return {
        model_name: pd.read_csv(prediction_file
            ).set_index('RedJade Code'
            ).loc[mol_codes]
        for model_name, prediction_file in files.items()
    }


def load_screening_ratings():
    return pd.read_csv(base.DATA_PATH / 'Data S2.csv')


def load_ratings(filter:Union[bool, Iterable]=True):
    """Load a dataframe with rater data and molecule metadata."""
    odor_key = pd.read_csv(base.DATA_PATH / 'Data S1.csv')
    
    ratings = pd.read_csv(base.DATA_PATH  / 'Data S3.csv')
    odor_key_fixed = odor_key[['RedJade Code', 'GC-O result',
                               'GC-O contaminant, if identified',
                               'Disqualification reason',
                               'Selection reason',
                              ]].rename(
            columns={'Odor Name': 'chemical_name', 'Kit': 'Round'})
    ratings = pd.merge(odor_key_fixed, ratings, how='inner',
                       right_on='SampleIdentifier', left_on='RedJade Code')

    if filter is True:
        ratings = ratings[ratings['Disqualification reason'].isna()]
    elif filter:  # filter is a list of disqualification reasons
        ratings = ratings[~ratings['Disqualification reason'].isin(filter)]
    return ratings


def get_clean(filter=True):
    # Load the data
    dfs = {}
    humans = load_ratings(filter=filter)
    mol_codes = humans['RedJade Code'].unique()
    models = load_gnn_rf_predictions(mol_codes)

    # Select the humans that rated at least some of these SMILES
    subjects = humans['SubjectCode'].unique()
    
    panel = humans.groupby('RedJade Code').mean().loc[mol_codes, base.MONELL_CLASS_LIST]
    
    return models, humans, panel, subjects


def load_embeddings():
    emb = np.load(base.DATA_PATH / 'gnn_embeddings.npz', allow_pickle=True)
    emb = pd.DataFrame(emb['prediction'], index=emb['smiles'])
    # Remove duplicate entries
    emb = emb[~emb.index.duplicated()]
    return emb


def load_redjade_smiles():
    return pd.read_csv(base.DATA_PATH / "Data S7.csv")
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API