Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/framing #1

Merged
merged 11 commits into from
Oct 24, 2023
Merged

Feature/framing #1

merged 11 commits into from
Oct 24, 2023

Conversation

iimpulse
Copy link
Member

Two module gradle project in java 17.

oan-etl will load are default ontology data like we do currently in hpo-web to a neo4j database.
oan-rest is a micronaut restful api to query this graph.

Copy link
Collaborator

@pnrobinson pnrobinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I can review this without getting a tour!

Copy link

@ielis ielis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @iimpulse see my comments below.

Cheers!

implementation("io.micronaut.serde:micronaut-serde-jackson")
implementation("io.micronaut.neo4j:micronaut-neo4j-bolt")
implementation("org.monarchinitiative.phenol:phenol-core:2.0.3"){
exclude group: 'org.slf4j', module: 'slf4j-api'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iimpulse just curious here, why do you exclude slf4j-api?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget lol, I think this came down to some version collision

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Maven, excluding would not be necessary, because the dependency that is higher in the dependency tree has a precedence. So, if you specify which version you want to use, e.g. in your top-level pom.xml, Maven will use that (more info here if you're interested, see the dependency mediation paragraph)

I think this principle sounds too useful to be Maven-specific. I would expect a similar behavior in Gradle, but 🤷‍♂️ ...

oan-etl/build.gradle Outdated Show resolved Hide resolved
}
}

protected void assayToPhenotype(Session session, File loinc){
Copy link

@ielis ielis Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this method (and the methods below) protected? Is this due to some framework which I am not aware of? Otherwise, why not to make them private?

Moreover, the methods do not use the class' state, hence they can be further "upgraded" to static.

EDIT: It looks like it's protected to enable testing. Note that you can get the same behavior with package-private visibility, although using the methods from unit tests should not be done in the long run.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean testing the load method over the individual pieces?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. I usually change the private/package-private bits and then I am forced to change the tests too..

tx.close();
}

protected void phenotypes(Session session, List<TermId> termIds, Ontology ontology){
Copy link

@ielis ielis Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method seems to be persisting HPO term IDs and the corresponding labels. The IDs originate from the HPOA but they are only persisted if there is a corresponding entry in the Ontology.

Why not iterate directly over the ontology terms and store the IDs and labels? That would achieve the same effect, if not better (here the IDs that are in the ontology and not in HPOA will be persisted).

In other words why not just store the Ontology nodes/terms?

Transaction tx = session.beginTransaction();
logger.info("Loading Disease to Phenotype Relationships...");
diseases.diseaseData().stream().flatMap(d -> d.annotationLines().stream()).forEach(line -> {
String onset = line.onset().map(HpoOnset::id).map(TermId::toString).orElse("");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the "" (empty string) equivalent to a missing value in NEO4J? I am not familiar with the semantics of the database, but "" and null can convey a different meaning..

The same applies for sex on L119 below.

for (TermId termId: termIds){
Optional<String> label = ontology.getTermLabel(termId);
label.ifPresent(s -> tx.run("CREATE (p:Phenotype {id: $id, name: $name})",
parameters("id", termId.toString(), "name", s)));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In TermId, the contract of toString is the same as contract of Display trait in Rust - show the data.
It just happens to be that it returns a good CURIE, but that's subject to change anytime.

Use getValue() if CURIE is what you want. I think that's what you're doing here, so really pls replace toString with getValue everywhere.

@iimpulse iimpulse merged commit da9b206 into main Oct 24, 2023
1 check passed
@iimpulse iimpulse deleted the feature/framing branch March 28, 2024 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants