Skip to content

Commit

Permalink
replace isadotnet by arctrl.isa dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Nov 22, 2023
1 parent a8c82ac commit d85e88b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
6 changes: 5 additions & 1 deletion src/OBO.NET/OBO.NET.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ARCtrl.ISA" Version="1.0.0-beta.7" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="[1.1.1]" PrivateAssets="All" />
<PackageReference Include="ISADotNet" Version="[0.6.1]" />
<PackageReference Include="FSharpAux" Version="[2.0.0]" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="7.0.401" />
</ItemGroup>

</Project>
38 changes: 19 additions & 19 deletions src/OBO.NET/OboOntology.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open DBXref
//open OboTypeDef

open FSharpAux
open ISADotNet
open ARCtrl.ISA

open System

Expand Down Expand Up @@ -149,26 +149,26 @@ type OboOntology =
/// For a given ontology term, finsd all equivalent terms that are connected via XRefs.
///
/// Depth can be used to restrict the number of iterations by which neighbours of neighbours are checked.
member this.GetEquivalentOntologyAnnotations(term : ISADotNet.OntologyAnnotation, ?Depth : int) =
member this.GetEquivalentOntologyAnnotations(term : OntologyAnnotation, ?Depth : int) =

let rec loop depth (equivalents : ISADotNet.OntologyAnnotation list) (lastLoop : ISADotNet.OntologyAnnotation list) =
let rec loop depth (equivalents : OntologyAnnotation list) (lastLoop : OntologyAnnotation list) =
if equivalents.Length = lastLoop.Length then equivalents
elif Depth.IsSome && Depth.Value < depth then equivalents
else
let newEquivalents =
equivalents
|> List.collect (fun t ->
let forward =
match this.TryGetTerm t.ShortAnnotationString with
match this.TryGetTerm t.TermAccessionShort with
| Some term ->
term.Xrefs
|> List.map (fun xref ->
let id = OntologyAnnotation.createShortAnnotation "" xref.Name
let id = OntologyAnnotation.fromTermAnnotation(xref.Name).TermAccessionShort
match this.TryGetOntologyAnnotation id with
| Some oa ->
oa
| None ->
OntologyAnnotation.fromString "" "" xref.Name
OntologyAnnotation.fromString(tan = xref.Name)
)
| None ->
[]
Expand All @@ -193,32 +193,32 @@ type OboOntology =
member this.GetEquivalentOntologyAnnotations(termId : string, ?Depth) =
match Depth with
| Some d ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> fun oa -> this.GetEquivalentOntologyAnnotations(oa, d)
| None ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> this.GetEquivalentOntologyAnnotations

/// For a given ontology term, finds all terms to which this term points in a "isA" relationship.
///
/// Depth can be used to restrict the number of iterations by which neighbours of neighbours are checked.
member this.GetParentOntologyAnnotations(term : ISADotNet.OntologyAnnotation, ?Depth) =
let rec loop depth (equivalents : ISADotNet.OntologyAnnotation list) (lastLoop : ISADotNet.OntologyAnnotation list) =
member this.GetParentOntologyAnnotations(term : OntologyAnnotation, ?Depth) =
let rec loop depth (equivalents : OntologyAnnotation list) (lastLoop : OntologyAnnotation list) =
if equivalents.Length = lastLoop.Length then equivalents
elif Depth.IsSome && Depth.Value < depth then equivalents
else
let newEquivalents =
equivalents
|> List.collect (fun t ->
match this.TryGetTerm t.ShortAnnotationString with
match this.TryGetTerm t.TermAccessionShort with
| Some term ->
term.IsA
|> List.map (fun isA ->
match this.TryGetOntologyAnnotation isA with
| Some oa ->
oa
| None ->
OntologyAnnotation.fromString "" "" isA
OntologyAnnotation.fromString(tan = isA)
)
| None ->
[]
Expand All @@ -233,17 +233,17 @@ type OboOntology =
member this.GetParentOntologyAnnotations(termId : string, ?Depth) =
match Depth with
| Some d ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> fun oa -> this.GetParentOntologyAnnotations(oa, d)
| None ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> this.GetParentOntologyAnnotations

/// For a given ontology term, finds all terms which point to this term "isA" relationship.
///
/// Depth can be used to restrict the number of iterations by which neighbours of neighbours are checked.
member this.GetChildOntologyAnnotations(term : ISADotNet.OntologyAnnotation, ?Depth) =
let rec loop depth (equivalents : ISADotNet.OntologyAnnotation list) (lastLoop : ISADotNet.OntologyAnnotation list) =
member this.GetChildOntologyAnnotations(term : OntologyAnnotation, ?Depth) =
let rec loop depth (equivalents : OntologyAnnotation list) (lastLoop : OntologyAnnotation list) =
if equivalents.Length = lastLoop.Length then equivalents
elif Depth.IsSome && Depth.Value < depth then equivalents
else
Expand All @@ -254,7 +254,7 @@ type OboOntology =
|> List.choose (fun pt ->
let isChild =
pt.IsA
|> List.exists (fun isA -> t.ShortAnnotationString = isA)
|> List.exists (fun isA -> t.TermAccessionShort = isA)
if isChild then
Some (OboTerm.toOntologyAnnotation(pt))
else
Expand All @@ -272,10 +272,10 @@ type OboOntology =
member this.GetChildOntologyAnnotations(termId : string, ?Depth) =
match Depth with
| Some d ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> fun oa -> this.GetChildOntologyAnnotations(oa, d)
| None ->
OntologyAnnotation.fromAnnotationId termId
OntologyAnnotation.fromTermAnnotation termId
|> this.GetChildOntologyAnnotations

/// Takes an OboTerm and returns all related terms in this ontology as a triple of input term, relationship, and related term.
Expand Down
8 changes: 4 additions & 4 deletions src/OBO.NET/OboTerm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
open DBXref
open TermSynonym

open ISADotNet
open ARCtrl.ISA

open System

Expand Down Expand Up @@ -515,12 +515,12 @@ type OboTerm =

/// Translates an OBO `term` into an ISADotNet `OntologyAnnotation`.
static member toOntologyAnnotation (term : OboTerm) =
let ref,num = OntologyAnnotation.splitAnnotation term.Id
OntologyAnnotation.fromString term.Name ref term.Id
OntologyAnnotation.fromString(term.Name,tan = term.Id)
|> fun o -> {o with TermSourceREF = o.TANInfo |> Option.map (fun t -> t.IDSpace)}

/// Translates an ISADotNet `OntologyAnnotation` into an OBO `term`.
static member ofOntologyAnnotation (term : OntologyAnnotation) =
OboTerm.Create(term.ShortAnnotationString,term.NameText)
OboTerm.Create(term.TermAccessionShort,term.NameText)

/// Takes a relationship and returns a tuple consisting of the name of the relationship and the ID of the OboTerm it matches.
static member deconstructRelationship relationship =
Expand Down

0 comments on commit d85e88b

Please sign in to comment.