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

Resolve Xrefs equivalence #36

Merged
merged 7 commits into from
Jun 6, 2024
Merged

Conversation

omaus
Copy link
Member

@omaus omaus commented Jun 4, 2024

This PR

  • incorporates ControlledVocabulary library
  • adds to and shifts functionality from DBXref module to its record type
    • such as the parsing function is now ofString
    • and new toCvTerm functionality
  • adds a function to return OboTerms as CvTerms
  • adds two functions to OboOntology
    • check for equivalence between two terms using the given ontology
    • getting all equivalent terms between two ontologies
  • has unit tests added for everything above

@omaus omaus requested a review from kMutagene June 4, 2024 10:36
@omaus omaus marked this pull request as ready for review June 4, 2024 10:37
Copy link
Member

@kMutagene kMutagene left a comment

Choose a reason for hiding this comment

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

Overall LGTM, small nitpick in the tests to fix and some general questions/remarks

Name : string
Description : string
Modifiers : string
}

/// Parses a given string to a DBXref
static member ofString (v : string) =
Copy link
Member

Choose a reason for hiding this comment

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

I do not understand why you are mixing static members and instance members here, is there a need for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Instance members are only possible on an already existing object. The ofString method creates a DBXref object.

@@ -519,6 +519,47 @@ type OboOntology =
static member getSynonyms term (onto : OboOntology) =
onto.GetSynonyms term

/// <summary>Checks if the given terms are treated as equivalent in the OboOntology.</summary>
/// <remarks>Note that term1 must be part of the OboOntology while term2 must be part of another ontology.</remarks>
Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine for now, but i think we should eventually either add a check here or add item accession to the terms in the ontology, e.g. ontology["termName"] should return the relevant term, so this method just needs to be this.AreTermsEquivalent(termName : string, externalTerm : OboTerm) = ....

Requiring one term being from the ontology without checking/enforcing it screams for unintended behavior IMO, but as said, fine for now

open System

open ARCtrl.ISA
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity, where is this reference needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are IsaOntologyAnnotation functions that use this. I think it's mainly used in ISA.NET and some subsequent projects but that was more like @HLWeil 's business.

Name = ""
Accession = this.Name
RefUri =
String.split ':' this.Name
Copy link
Member

Choose a reason for hiding this comment

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

Is this reliable? Will all TAN have this shape? Just curious, i don't know the answer myself

Copy link
Member Author

Choose a reason for hiding this comment

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

The OBO Flat File Format section defines it this way, but with SHOULD.
I, myself, should therefore add a try with there. 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

Nvm., String.split does not throw if there's not the given delimiter. It just returns an array with the input string as single item:

String.split ':' "klsdklsd"

val it: string[] = [|"klsdklsd"|]

Therefore, no need to do anything here, and I'm fine with this output for IDs that don't follow the format recommendations.

testList "ReturnAllEquivalentTerms" [
testCase "returns correct terms" <| fun _ ->
let actual = testOntology.ReturnAllEquivalentTerms(testOntology2)
Expect.equal (Seq.head actual).Id testTerm4.Id "is not equal"
Copy link
Member

Choose a reason for hiding this comment

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

Since you are testing a sequence here, i would test the whole sequence instead of just the head

Copy link
Member Author

@omaus omaus Jun 5, 2024

Choose a reason for hiding this comment

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

Then it would compare objects and they are not equal (due to reference). Or does Expecto circumvent this by checking the fields' values via reflection? 🤔
(I'm not sure but) I think not.
Gonna test it.

Copy link
Member

Choose a reason for hiding this comment

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

There is Expect.SequenceEqual.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I'm talkin' 'bout. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but this is not what I was about.
Nevertheless, for record types there's structural equality and checks for every field. Therefore, this should be no problem. 👍🏻

@omaus
Copy link
Member Author

omaus commented Jun 6, 2024

Requests are done, ready for rereview! 😃 @kMutagene

@omaus omaus requested a review from kMutagene June 6, 2024 09:18
@omaus omaus merged commit d9e7b85 into main Jun 6, 2024
2 checks passed
@omaus omaus deleted the feature-resolveXrefsEquivalent-#34 branch June 6, 2024 10:08
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.

2 participants