From 38994eb8d86ee2779d1f52e5d48cb93f058b7e99 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 16 Apr 2017 22:42:07 -0500 Subject: [PATCH] Done --- csharp/{ncbo => }/ncbo.sln | 0 csharp/ncbo/{ncbo => }/AnnotateText.cs | 2 +- csharp/ncbo/{ncbo => }/ClassesSearch.cs | 0 csharp/ncbo/{ncbo => }/Common/Constants.cs | 0 csharp/ncbo/{ncbo => }/Common/Network.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/AnnotatedClass.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/Annotation.cs | 0 .../{ncbo => }/DataTypes/AnnotationCollection.cs | 0 .../ncbo/{ncbo => }/DataTypes/AnnotationLinks.cs | 0 .../ncbo/{ncbo => }/DataTypes/AnnotationResult.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/Ontology.cs | 2 + csharp/ncbo/{ncbo => }/DataTypes/OntologyLink.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/Page.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/PageCollection.cs | 0 csharp/ncbo/{ncbo => }/DataTypes/PageLink.cs | 0 csharp/ncbo/DataTypes/ResourceContext.cs | 39 ++++++++++++++ csharp/ncbo/DataTypes/ResourceLinks.cs | 59 ++++++++++++++++++++++ csharp/ncbo/DataTypes/Resources.cs | 13 +++++ csharp/ncbo/{ncbo => }/GetLabels.cs | 2 - csharp/ncbo/ListOntologies.cs | 27 ++++++++++ csharp/ncbo/Program.cs | 33 ++++++++++++ csharp/ncbo/{ncbo => }/classes_search_terms.txt | 0 csharp/ncbo/{ncbo => }/ncbo.csproj | 0 csharp/ncbo/ncbo/Program.cs | 21 -------- 24 files changed, 174 insertions(+), 24 deletions(-) rename csharp/{ncbo => }/ncbo.sln (100%) rename csharp/ncbo/{ncbo => }/AnnotateText.cs (99%) rename csharp/ncbo/{ncbo => }/ClassesSearch.cs (100%) rename csharp/ncbo/{ncbo => }/Common/Constants.cs (100%) rename csharp/ncbo/{ncbo => }/Common/Network.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/AnnotatedClass.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/Annotation.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/AnnotationCollection.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/AnnotationLinks.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/AnnotationResult.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/Ontology.cs (90%) rename csharp/ncbo/{ncbo => }/DataTypes/OntologyLink.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/Page.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/PageCollection.cs (100%) rename csharp/ncbo/{ncbo => }/DataTypes/PageLink.cs (100%) create mode 100644 csharp/ncbo/DataTypes/ResourceContext.cs create mode 100644 csharp/ncbo/DataTypes/ResourceLinks.cs create mode 100644 csharp/ncbo/DataTypes/Resources.cs rename csharp/ncbo/{ncbo => }/GetLabels.cs (97%) create mode 100644 csharp/ncbo/ListOntologies.cs create mode 100644 csharp/ncbo/Program.cs rename csharp/ncbo/{ncbo => }/classes_search_terms.txt (100%) rename csharp/ncbo/{ncbo => }/ncbo.csproj (100%) delete mode 100644 csharp/ncbo/ncbo/Program.cs diff --git a/csharp/ncbo/ncbo.sln b/csharp/ncbo.sln similarity index 100% rename from csharp/ncbo/ncbo.sln rename to csharp/ncbo.sln diff --git a/csharp/ncbo/ncbo/AnnotateText.cs b/csharp/ncbo/AnnotateText.cs similarity index 99% rename from csharp/ncbo/ncbo/AnnotateText.cs rename to csharp/ncbo/AnnotateText.cs index 8ca771f..9d2d7d4 100644 --- a/csharp/ncbo/ncbo/AnnotateText.cs +++ b/csharp/ncbo/AnnotateText.cs @@ -18,7 +18,7 @@ private static void PrintAnnotations(AnnotationResult[] annotationResults) Console.WriteLine("Class details"); Console.WriteLine("\tID: " + annotationPage.ID); Console.WriteLine("\tPrefLabel: " + annotationPage.PrefLabel); - Console.WriteLine("\tOntology: " + annotationPage.Links.Ontology); + Console.WriteLine("\tOntology: " + annotationPage.Links?.Ontology); Console.WriteLine("Annotation details"); foreach(Annotation annotation in annotationResult.Annotations) diff --git a/csharp/ncbo/ncbo/ClassesSearch.cs b/csharp/ncbo/ClassesSearch.cs similarity index 100% rename from csharp/ncbo/ncbo/ClassesSearch.cs rename to csharp/ncbo/ClassesSearch.cs diff --git a/csharp/ncbo/ncbo/Common/Constants.cs b/csharp/ncbo/Common/Constants.cs similarity index 100% rename from csharp/ncbo/ncbo/Common/Constants.cs rename to csharp/ncbo/Common/Constants.cs diff --git a/csharp/ncbo/ncbo/Common/Network.cs b/csharp/ncbo/Common/Network.cs similarity index 100% rename from csharp/ncbo/ncbo/Common/Network.cs rename to csharp/ncbo/Common/Network.cs diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs b/csharp/ncbo/DataTypes/AnnotatedClass.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs rename to csharp/ncbo/DataTypes/AnnotatedClass.cs diff --git a/csharp/ncbo/ncbo/DataTypes/Annotation.cs b/csharp/ncbo/DataTypes/Annotation.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/Annotation.cs rename to csharp/ncbo/DataTypes/Annotation.cs diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs b/csharp/ncbo/DataTypes/AnnotationCollection.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs rename to csharp/ncbo/DataTypes/AnnotationCollection.cs diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs b/csharp/ncbo/DataTypes/AnnotationLinks.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs rename to csharp/ncbo/DataTypes/AnnotationLinks.cs diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs b/csharp/ncbo/DataTypes/AnnotationResult.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs rename to csharp/ncbo/DataTypes/AnnotationResult.cs diff --git a/csharp/ncbo/ncbo/DataTypes/Ontology.cs b/csharp/ncbo/DataTypes/Ontology.cs similarity index 90% rename from csharp/ncbo/ncbo/DataTypes/Ontology.cs rename to csharp/ncbo/DataTypes/Ontology.cs index 1c41352..5cd1de2 100644 --- a/csharp/ncbo/ncbo/DataTypes/Ontology.cs +++ b/csharp/ncbo/DataTypes/Ontology.cs @@ -7,6 +7,8 @@ namespace ncbo.DataTypes { public class Ontology { + [JsonProperty("@id")] + public string ID { get; set; } [JsonProperty("administeredBy")] public string[] AdministeredBy { get; set; } [JsonProperty("acronym")] diff --git a/csharp/ncbo/ncbo/DataTypes/OntologyLink.cs b/csharp/ncbo/DataTypes/OntologyLink.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/OntologyLink.cs rename to csharp/ncbo/DataTypes/OntologyLink.cs diff --git a/csharp/ncbo/ncbo/DataTypes/Page.cs b/csharp/ncbo/DataTypes/Page.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/Page.cs rename to csharp/ncbo/DataTypes/Page.cs diff --git a/csharp/ncbo/ncbo/DataTypes/PageCollection.cs b/csharp/ncbo/DataTypes/PageCollection.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/PageCollection.cs rename to csharp/ncbo/DataTypes/PageCollection.cs diff --git a/csharp/ncbo/ncbo/DataTypes/PageLink.cs b/csharp/ncbo/DataTypes/PageLink.cs similarity index 100% rename from csharp/ncbo/ncbo/DataTypes/PageLink.cs rename to csharp/ncbo/DataTypes/PageLink.cs diff --git a/csharp/ncbo/DataTypes/ResourceContext.cs b/csharp/ncbo/DataTypes/ResourceContext.cs new file mode 100644 index 0000000..99aec31 --- /dev/null +++ b/csharp/ncbo/DataTypes/ResourceContext.cs @@ -0,0 +1,39 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class ResourceContext + { + [JsonProperty("submissions")] + public string Submissions { get; set; } + [JsonProperty("notes")] + public string Notes { get; set; } + [JsonProperty("categories")] + public string Categories { get; set; } + [JsonProperty("provisional_classes")] + public string ProvisionalClasses { get; set; } + [JsonProperty("slices")] + public string Slices { get; set; } + [JsonProperty("metrics")] + public string Metrics { get; set; } + [JsonProperty("mappings")] + public string Mappings { get; set; } + [JsonProperty("users")] + public string Users { get; set; } + [JsonProperty("projects")] + public string Projects { get; set; } + [JsonProperty("ontologies")] + public string Ontologies { get; set; } + [JsonProperty("groups")] + public string Groups { get; set; } + [JsonProperty("replies")] + public string Replies { get; set; } + [JsonProperty("provisional_relations")] + public string ProvisionalRelations { get; set; } + [JsonProperty("reviews")] + public string Reviews { get; set; } + } +} diff --git a/csharp/ncbo/DataTypes/ResourceLinks.cs b/csharp/ncbo/DataTypes/ResourceLinks.cs new file mode 100644 index 0000000..d6cb1a2 --- /dev/null +++ b/csharp/ncbo/DataTypes/ResourceLinks.cs @@ -0,0 +1,59 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class ResourceLinks + { + [JsonProperty("submissions")] + public string Submissions { get; set; } + [JsonProperty("notes")] + public string Notes { get; set; } + [JsonProperty("categories")] + public string Categories { get; set; } + [JsonProperty("provisional_classes")] + public string ProvisionalClasses { get; set; } + [JsonProperty("annotator")] + public string Annotator { get; set; } + [JsonProperty("resource_index")] + public string ResourceIndex { get; set; } + [JsonProperty("documentation")] + public string Documentation { get; set; } + [JsonProperty("slices")] + public string Slices { get; set; } + [JsonProperty("metrics")] + public string Metrics { get; set; } + [JsonProperty("mappings")] + public string Mappings { get; set; } + [JsonProperty("users")] + public string Users { get; set; } + [JsonProperty("search")] + public string Search { get; set; } + [JsonProperty("projects")] + public string Projects { get; set; } + [JsonProperty("ontologies")] + public string Ontologies { get; set; } + [JsonProperty("ccv")] + public string CCV { get; set; } + [JsonProperty("recommender")] + public string Recommender { get; set; } + [JsonProperty("groups")] + public string Groups { get; set; } + [JsonProperty("replies")] + public string Replies { get; set; } + [JsonProperty("recommender_v1")] + public string RecommenderV1 { get; set; } + [JsonProperty("provisional_relations")] + public string ProvisionalRelations { get; set; } + [JsonProperty("property_search")] + public string PropertySearch { get; set; } + [JsonProperty("analytics")] + public string Analytics { get; set; } + [JsonProperty("reviews")] + public string Reviews { get; set; } + [JsonProperty("@context")] + public ResourceContext Context { get; set; } +} +} diff --git a/csharp/ncbo/DataTypes/Resources.cs b/csharp/ncbo/DataTypes/Resources.cs new file mode 100644 index 0000000..16bfc53 --- /dev/null +++ b/csharp/ncbo/DataTypes/Resources.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class Resources + { + [JsonProperty("links")] + public ResourceLinks Links { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/GetLabels.cs b/csharp/ncbo/GetLabels.cs similarity index 97% rename from csharp/ncbo/ncbo/GetLabels.cs rename to csharp/ncbo/GetLabels.cs index 9eedf83..8a232b4 100644 --- a/csharp/ncbo/ncbo/GetLabels.cs +++ b/csharp/ncbo/GetLabels.cs @@ -44,8 +44,6 @@ public static void DoIt() { Console.WriteLine(label); } - - Console.ReadLine(); } } } diff --git a/csharp/ncbo/ListOntologies.cs b/csharp/ncbo/ListOntologies.cs new file mode 100644 index 0000000..fd7a8b2 --- /dev/null +++ b/csharp/ncbo/ListOntologies.cs @@ -0,0 +1,27 @@ +using ncbo.Common; +using ncbo.DataTypes; +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; + +namespace ncbo +{ + public static class ListOntologies + { + public static void DoIt() + { + Resources resources = Network.GetResponseAs("http://data.bioontology.org"); + + Ontology[] ontologies = Network.GetResponseAs(resources.Links.Ontologies); + + IEnumerable ontologyStrings = ontologies.Select(n => n.Name + Environment.NewLine + + n.ID + Environment.NewLine + Environment.NewLine); + + foreach(string ontologyString in ontologyStrings) + { + Console.WriteLine(ontologyString); + } + } + } +} diff --git a/csharp/ncbo/Program.cs b/csharp/ncbo/Program.cs new file mode 100644 index 0000000..2b5341e --- /dev/null +++ b/csharp/ncbo/Program.cs @@ -0,0 +1,33 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Threading.Tasks; + +namespace ncbo +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("GetLabels:"); + GetLabels.DoIt(); + + Console.WriteLine(); + Console.WriteLine("AnnotateText:"); + AnnotateText.DoIt(); + + Console.WriteLine(); + Console.WriteLine("ClassesSearch"); + ClassesSearch.DoIt(); + + Console.WriteLine(); + Console.WriteLine("ListOntologies"); + ListOntologies.DoIt(); + + Console.WriteLine("Done"); + Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/csharp/ncbo/ncbo/classes_search_terms.txt b/csharp/ncbo/classes_search_terms.txt similarity index 100% rename from csharp/ncbo/ncbo/classes_search_terms.txt rename to csharp/ncbo/classes_search_terms.txt diff --git a/csharp/ncbo/ncbo/ncbo.csproj b/csharp/ncbo/ncbo.csproj similarity index 100% rename from csharp/ncbo/ncbo/ncbo.csproj rename to csharp/ncbo/ncbo.csproj diff --git a/csharp/ncbo/ncbo/Program.cs b/csharp/ncbo/ncbo/Program.cs deleted file mode 100644 index e3f6ca1..0000000 --- a/csharp/ncbo/ncbo/Program.cs +++ /dev/null @@ -1,21 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; - -namespace ncbo -{ - class Program - { - static void Main(string[] args) - { - //GetLabels.DoIt(); - - //AnnotateText.DoIt(); - - ClassesSearch.DoIt(); - } - } -} \ No newline at end of file