Skip to content

Commit

Permalink
Merge pull request #337 from nfdi4plants/ToStringOverrides
Browse files Browse the repository at this point in the history
Add ToString overrides for study/investigation
  • Loading branch information
HLWeil authored Apr 5, 2024
2 parents 9ebd796 + 98c5228 commit 3a5c89a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions ARCtrl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{501F6D
ProjectSection(SolutionItems) = preProject
tests\Python\test_index.py = tests\Python\test_index.py
tests\Python\test_JsonController.py = tests\Python\test_JsonController.py
tests\Python\test_OntologyAnnotation.py = tests\Python\test_OntologyAnnotation.py
tests\Python\test_XlsxController.py = tests\Python\test_XlsxController.py
EndProjectSection
EndProject
Expand Down
62 changes: 61 additions & 1 deletion src/Core/ArcTypes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,34 @@ type ArcStudy(identifier : string, ?title, ?description, ?submissionDate, ?publi
/// <param name="other">The other ArcStudy to test for reference.</param>
member this.ReferenceEquals (other: ArcStudy) = System.Object.ReferenceEquals(this,other)

// Use this for better print debugging and better unit test output
override this.ToString() =
sprintf
"""ArcStudy {
Identifier = %A,
Title = %A,
Description = %A,
SubmissionDate = %A,
PublicReleaseDate = %A,
Publications = %A,
Contacts = %A,
StudyDesignDescriptors = %A,
Tables = %A,
RegisteredAssayIdentifiers = %A,
Comments = %A,
}"""
this.Identifier
this.Title
this.Description
this.SubmissionDate
this.PublicReleaseDate
this.Publications
this.Contacts
this.StudyDesignDescriptors
this.Tables
this.RegisteredAssayIdentifiers
this.Comments

// custom check
override this.Equals other =
match other with
Expand Down Expand Up @@ -1744,7 +1772,39 @@ type ArcInvestigation(identifier : string, ?title : string, ?description : strin
/// If true, updating one will update the other due to mutability.
/// </summary>
/// <param name="other">The other ArcInvestigation to test for reference.</param>
member this.ReferenceEquals (other: ArcStudy) = System.Object.ReferenceEquals(this,other)
member this.ReferenceEquals (other: ArcInvestigation) = System.Object.ReferenceEquals(this,other)

// Use this for better print debugging and better unit test output
override this.ToString() =
sprintf
"""ArcStudy {
Identifier = %A,
Title = %A,
Description = %A,
SubmissionDate = %A,
PublicReleaseDate = %A,
OntologySourceReferences = %A,
Publications = %A,
Contacts = %A,
Assays = %A,
Studies = %A,
RegisteredStudyIdentifiers = %A,
Comments = %A,
Remarks = %A,
}"""
this.Identifier
this.Title
this.Description
this.SubmissionDate
this.PublicReleaseDate
this.OntologySourceReferences
this.Publications
this.Contacts
this.Assays
this.Studies
this.RegisteredStudyIdentifiers
this.Comments
this.Remarks

// custom check
override this.Equals other =
Expand Down
8 changes: 8 additions & 0 deletions tests/Python/test_OntologyAnnotation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .ARCtrl.arctrl import OntologyAnnotation, JsonController, ArcInvestigation

class TestOntologyAnnotation:

def test_create(self):
oa = OntologyAnnotation("instrument model", "MS", "MS:1234567")
assert oa.NameText == "instrument model"

0 comments on commit 3a5c89a

Please sign in to comment.