From 5096630991840c2886e1c37bdf15de8080b9dbb9 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 15 Apr 2017 18:45:49 -0500 Subject: [PATCH 1/4] Pulls back pref labels. --- .gitignore | 289 +++++++++++++++++++++++++++ csharp/ncbo/ncbo.sln | 22 ++ csharp/ncbo/ncbo/Common/Network.cs | 32 +++ csharp/ncbo/ncbo/DataTypes/Ontology.cs | 23 +++ csharp/ncbo/ncbo/DataTypes/OntologyLink.cs | 45 +++++ csharp/ncbo/ncbo/DataTypes/Page.cs | 25 +++ csharp/ncbo/ncbo/DataTypes/PageCollection.cs | 25 +++ csharp/ncbo/ncbo/DataTypes/PageLink.cs | 15 ++ csharp/ncbo/ncbo/GetLabels.cs | 51 +++++ csharp/ncbo/ncbo/Program.cs | 17 ++ csharp/ncbo/ncbo/TextFile1.txt | 11 + csharp/ncbo/ncbo/ncbo.csproj | 18 ++ 12 files changed, 573 insertions(+) create mode 100644 csharp/ncbo/ncbo.sln create mode 100644 csharp/ncbo/ncbo/Common/Network.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/Ontology.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/OntologyLink.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/Page.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/PageCollection.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/PageLink.cs create mode 100644 csharp/ncbo/ncbo/GetLabels.cs create mode 100644 csharp/ncbo/ncbo/Program.cs create mode 100644 csharp/ncbo/ncbo/TextFile1.txt create mode 100644 csharp/ncbo/ncbo/ncbo.csproj diff --git a/.gitignore b/.gitignore index fab6527..d53e491 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,292 @@ java/nbproject/* # IntelliJ java/.idea/* java/*.iml + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ +**/Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Typescript v1 declaration files +typings/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs diff --git a/csharp/ncbo/ncbo.sln b/csharp/ncbo/ncbo.sln new file mode 100644 index 0000000..c5fcd42 --- /dev/null +++ b/csharp/ncbo/ncbo.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ncbo", "ncbo\ncbo.csproj", "{AC37CC07-66F9-4F08-A5A4-B65316598005}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AC37CC07-66F9-4F08-A5A4-B65316598005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC37CC07-66F9-4F08-A5A4-B65316598005}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC37CC07-66F9-4F08-A5A4-B65316598005}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC37CC07-66F9-4F08-A5A4-B65316598005}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/csharp/ncbo/ncbo/Common/Network.cs b/csharp/ncbo/ncbo/Common/Network.cs new file mode 100644 index 0000000..bb035bf --- /dev/null +++ b/csharp/ncbo/ncbo/Common/Network.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace ncbo.Common +{ + public static class Network + { + public static string GetJsonResponse(string url) + { + HttpClient web = new HttpClient(); + web.DefaultRequestHeaders.Add("Authorization", "apikey token=5cddf159-a650-4458-b802-cb5936567668"); + Task asyncResponse = web.GetAsync(url); + asyncResponse.Wait(); + HttpResponseMessage response = asyncResponse.Result; + + Task asyncString = response.Content.ReadAsStringAsync(); + asyncString.Wait(); + + return asyncString.Result; + } + + public static T GetResponseAs(string url) + { + string jsonResponse = GetJsonResponse(url); + return JsonConvert.DeserializeObject(jsonResponse); + } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/Ontology.cs b/csharp/ncbo/ncbo/DataTypes/Ontology.cs new file mode 100644 index 0000000..1c41352 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/Ontology.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class Ontology + { + [JsonProperty("administeredBy")] + public string[] AdministeredBy { get; set; } + [JsonProperty("acronym")] + public string Acronym { get; set; } + [JsonProperty("name")] + public string Name { get; set; } + [JsonProperty("summaryOnly")] + public string SummaryOnly { get; set; } + [JsonProperty("ontologyType")] + public string OntologyType { get; set; } + [JsonProperty("links")] + public OntologyLink Links { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/OntologyLink.cs b/csharp/ncbo/ncbo/DataTypes/OntologyLink.cs new file mode 100644 index 0000000..97b6bd6 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/OntologyLink.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class OntologyLink + { + [JsonProperty("submissions")] + public string Submissions { get; set; } + [JsonProperty("properties")] + public string Properties { get; set; } + [JsonProperty("classes")] + public string Classes { get; set; } + [JsonProperty("single_class")] + public string SingleClass { get; set; } + [JsonProperty("roots")] + public string Roots { get; set; } + [JsonProperty("instances")] + public string Instances { get; set; } + [JsonProperty("metrics")] + public string Metrics { get; set; } + [JsonProperty("reviews")] + public string Reviews { get; set; } + [JsonProperty("notes")] + public string Notes { get; set; } + [JsonProperty("groups")] + public string Groups { get; set; } + [JsonProperty("categories")] + public string Categories { get; set; } + [JsonProperty("latest_submission")] + public string LatestSubmission { get; set; } + [JsonProperty("projects")] + public string Projects { get; set; } + [JsonProperty("download")] + public string Download { get; set; } + [JsonProperty("views")] + public string Views { get; set; } + [JsonProperty("analytics")] + public string Analytics { get; set; } + [JsonProperty("ui")] + public string UI { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/Page.cs b/csharp/ncbo/ncbo/DataTypes/Page.cs new file mode 100644 index 0000000..87bd0d4 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/Page.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class Page + { + [JsonProperty("page")] + public int PageNumber { get; set; } + [JsonProperty("pageCount")] + public int PageCount { get; set; } + [JsonProperty("totalCount")] + public int TotalCount { get; set; } + [JsonProperty("prevPage")] + public string PrevPage { get; set; } + [JsonProperty("nextPage")] + public int? NextPageNumber { get; set; } + [JsonProperty("links")] + public PageLink Link { get; set; } + [JsonProperty("collection")] + public List Collections { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/PageCollection.cs b/csharp/ncbo/ncbo/DataTypes/PageCollection.cs new file mode 100644 index 0000000..c6962e2 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/PageCollection.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class PageCollection + { + [JsonProperty("prefLabel")] + public string PrefLabel { get; set; } + [JsonProperty("synonym")] + public List Synonym { get; set; } + [JsonProperty("definition")] + public List Definition { get; set; } + [JsonProperty("cui")] + public List CUI { get; set; } + [JsonProperty("semanticType")] + public List SemanticType { get; set; } + [JsonProperty("obsolete")] + public bool Obsolete { get; set; } + [JsonProperty("links")] + public PageLink Links { get; set; } +} +} diff --git a/csharp/ncbo/ncbo/DataTypes/PageLink.cs b/csharp/ncbo/ncbo/DataTypes/PageLink.cs new file mode 100644 index 0000000..f939d5f --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/PageLink.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class PageLink + { + [JsonProperty("nextPage")] + public string NextPageUrl { get; set; } + [JsonProperty("prevPage")] + public string PrevPageUrl { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/GetLabels.cs b/csharp/ncbo/ncbo/GetLabels.cs new file mode 100644 index 0000000..b0b0f58 --- /dev/null +++ b/csharp/ncbo/ncbo/GetLabels.cs @@ -0,0 +1,51 @@ +using ncbo.Common; +using ncbo.DataTypes; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; + +namespace ncbo +{ + public static class GetLabels + { + public static void DoIt() + { + // Get all ontologies from the REST service and parse the JSON + Ontology[] ontology = Network.GetResponseAs("http://data.bioontology.org/ontologies"); + + Ontology broOntology = ontology.Where(n => n.Acronym == "BRO").FirstOrDefault(); + + string classesPageUrl = broOntology.Links.Classes; + + Page page = Network.GetResponseAs(classesPageUrl); + + List labels = new List(); + for(;;) + { + string nextPageUrl = page.Link.NextPageUrl; + foreach(PageCollection collection in page.Collections) + { + labels.Add(collection.PrefLabel); + } + + if(!string.IsNullOrEmpty(nextPageUrl)) + { + page = Network.GetResponseAs(nextPageUrl); + } + else + { + break; + } + } + + foreach(string label in labels) + { + Console.WriteLine(label); + } + + Console.ReadLine(); + } + } +} diff --git a/csharp/ncbo/ncbo/Program.cs b/csharp/ncbo/ncbo/Program.cs new file mode 100644 index 0000000..eba2720 --- /dev/null +++ b/csharp/ncbo/ncbo/Program.cs @@ -0,0 +1,17 @@ +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(); + } + } +} \ No newline at end of file diff --git a/csharp/ncbo/ncbo/TextFile1.txt b/csharp/ncbo/ncbo/TextFile1.txt new file mode 100644 index 0000000..470e6bc --- /dev/null +++ b/csharp/ncbo/ncbo/TextFile1.txt @@ -0,0 +1,11 @@ +{"menu": { + "id": "file", + "value": "File", + "popup": { + "menuitem": [ + {"value": "New", "onclick": "CreateNewDoc()"}, + {"value": "Open", "onclick": "OpenDoc()"}, + {"value": "Close", "onclick": "CloseDoc()"} + ] + } +}} \ No newline at end of file diff --git a/csharp/ncbo/ncbo/ncbo.csproj b/csharp/ncbo/ncbo/ncbo.csproj new file mode 100644 index 0000000..fb211d3 --- /dev/null +++ b/csharp/ncbo/ncbo/ncbo.csproj @@ -0,0 +1,18 @@ + + + + Exe + netcoreapp1.1 + + + + + + + + + Always + + + + \ No newline at end of file From 3d6dfb3a6f0388796c6676d9b913ca027f88be25 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 16 Apr 2017 19:30:07 -0500 Subject: [PATCH 2/4] Annotations. --- csharp/ncbo/ncbo/AnnotateText.cs | 64 ++++++++++++++++++++++ csharp/ncbo/ncbo/Common/Constants.cs | 11 ++++ csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs | 15 +++++ csharp/ncbo/ncbo/DataTypes/Annotation.cs | 19 +++++++ csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs | 27 +++++++++ csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs | 30 ++++++++++ csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs | 19 +++++++ csharp/ncbo/ncbo/DataTypes/Page.cs | 2 +- csharp/ncbo/ncbo/DataTypes/PageCollection.cs | 6 +- csharp/ncbo/ncbo/DataTypes/PageLink.cs | 2 +- csharp/ncbo/ncbo/GetLabels.cs | 2 +- csharp/ncbo/ncbo/Program.cs | 4 +- 12 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 csharp/ncbo/ncbo/AnnotateText.cs create mode 100644 csharp/ncbo/ncbo/Common/Constants.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/Annotation.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs create mode 100644 csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs diff --git a/csharp/ncbo/ncbo/AnnotateText.cs b/csharp/ncbo/ncbo/AnnotateText.cs new file mode 100644 index 0000000..8ca771f --- /dev/null +++ b/csharp/ncbo/ncbo/AnnotateText.cs @@ -0,0 +1,64 @@ +using ncbo.Common; +using System; +using System.Collections.Generic; +using System.Text; +using ncbo.DataTypes; + +namespace ncbo +{ + public static class AnnotateText + { + private static void PrintAnnotations(AnnotationResult[] annotationResults) + { + foreach(AnnotationResult annotationResult in annotationResults) + { + AnnotationPage annotationPage = + Network.GetResponseAs(annotationResult.AnnotatedClass.Link.Self); + + Console.WriteLine("Class details"); + Console.WriteLine("\tID: " + annotationPage.ID); + Console.WriteLine("\tPrefLabel: " + annotationPage.PrefLabel); + Console.WriteLine("\tOntology: " + annotationPage.Links.Ontology); + + Console.WriteLine("Annotation details"); + foreach(Annotation annotation in annotationResult.Annotations) + { + Console.WriteLine("\tFrom: " + annotation.From); + Console.WriteLine("\tTo: " + annotation.To); + Console.WriteLine("\tMatch type: " + annotation.MatchType); + } + + if(annotationResult.Hierarchy!=null && annotationResult.Hierarchy.Count > 0) + { + Console.WriteLine("Hierachy Annotations"); + foreach (AnnotatedClass annotatedClass in annotationResult.Hierarchy) + { + AnnotationPage annotationHierarchyPage = + Network.GetResponseAs(annotationResult.AnnotatedClass.Link.Self); + + Console.WriteLine("\tClass details"); + Console.WriteLine("\t\tID: " + annotationHierarchyPage.ID); + Console.WriteLine("\t\tPrefLabel: " + annotationHierarchyPage.PrefLabel); + Console.WriteLine("\t\tOntology: " + annotationHierarchyPage.Links.Ontology); + Console.WriteLine("\t\tDistance from originally annotated class: : " + annotatedClass.Distance); + } + } + + Console.WriteLine("===="); + } + } + + public static void DoIt() + { + string textToAnnotate = + "Melanoma is a malignant tumor of melanocytes which are found " + + "predominantly in skin but also in the bowel and the eye."; + + AnnotationResult[] annotationResults = + Network.GetResponseAs(Constants.BaseUrl + "/annotator?text=" + textToAnnotate); + + PrintAnnotations(annotationResults); + } + } +} + \ No newline at end of file diff --git a/csharp/ncbo/ncbo/Common/Constants.cs b/csharp/ncbo/ncbo/Common/Constants.cs new file mode 100644 index 0000000..64630d7 --- /dev/null +++ b/csharp/ncbo/ncbo/Common/Constants.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.Common +{ + public static class Constants + { + public static string BaseUrl = "http://data.bioontology.org"; + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs b/csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs new file mode 100644 index 0000000..919f190 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/AnnotatedClass.cs @@ -0,0 +1,15 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class AnnotatedClass + { + [JsonProperty("links")] + public AnnotationLinks Link { get; set; } + [JsonProperty("distance")] + public int Distance { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/Annotation.cs b/csharp/ncbo/ncbo/DataTypes/Annotation.cs new file mode 100644 index 0000000..47709c2 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/Annotation.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class Annotation + { + [JsonProperty("from")] + public int From { get; set; } + [JsonProperty("to")] + public int To { get; set; } + [JsonProperty("matchType")] + public string MatchType { get; set; } + [JsonProperty("text")] + public string Text { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs b/csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs new file mode 100644 index 0000000..2717ba4 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/AnnotationCollection.cs @@ -0,0 +1,27 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class AnnotationPage + { + [JsonProperty("@id")] + public string ID { get; set; } + [JsonProperty("prefLabel")] + public string PrefLabel { get; set; } + [JsonProperty("synonym")] + public List Synonym { get; set; } + [JsonProperty("definition")] + public List Definition { get; set; } + [JsonProperty("cui")] + public List CUI { get; set; } + [JsonProperty("semanticType")] + public List SemanticType { get; set; } + [JsonProperty("obsolete")] + public bool Obsolete { get; set; } + [JsonProperty("links")] + public AnnotationLinks Links { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs b/csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs new file mode 100644 index 0000000..e7fb1bc --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/AnnotationLinks.cs @@ -0,0 +1,30 @@ +using Newtonsoft.Json; + +namespace ncbo.DataTypes +{ + public class AnnotationLinks + { + [JsonProperty("self")] + public string Self { get; set; } + [JsonProperty("ontology")] + public string Ontology { get; set; } + [JsonProperty("children")] + public string Children { get; set; } + [JsonProperty("parents")] + public string Parents { get; set; } + [JsonProperty("descendants")] + public string Descendants { get; set; } + [JsonProperty("ancestors")] + public string Ancestors { get; set; } + [JsonProperty("instances")] + public string Instances { get; set; } + [JsonProperty("tree")] + public string Tree { get; set; } + [JsonProperty("notes")] + public string Notes { get; set; } + [JsonProperty("mappings")] + public string Mappings { get; set; } + [JsonProperty("ui")] + public string UI { get; set; } + } +} \ No newline at end of file diff --git a/csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs b/csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs new file mode 100644 index 0000000..3589ec0 --- /dev/null +++ b/csharp/ncbo/ncbo/DataTypes/AnnotationResult.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace ncbo.DataTypes +{ + public class AnnotationResult + { + [JsonProperty("annotatedClass")] + public AnnotatedClass AnnotatedClass { get; set; } + [JsonProperty("hierarchy")] + public List Hierarchy { get; set; } + [JsonProperty("annotations")] + public List Annotations { get; set; } + [JsonProperty("mappings")] + public List Mappings { get; set; } + } +} diff --git a/csharp/ncbo/ncbo/DataTypes/Page.cs b/csharp/ncbo/ncbo/DataTypes/Page.cs index 87bd0d4..cc83b6b 100644 --- a/csharp/ncbo/ncbo/DataTypes/Page.cs +++ b/csharp/ncbo/ncbo/DataTypes/Page.cs @@ -18,7 +18,7 @@ public class Page [JsonProperty("nextPage")] public int? NextPageNumber { get; set; } [JsonProperty("links")] - public PageLink Link { get; set; } + public PageLinks Link { get; set; } [JsonProperty("collection")] public List Collections { get; set; } } diff --git a/csharp/ncbo/ncbo/DataTypes/PageCollection.cs b/csharp/ncbo/ncbo/DataTypes/PageCollection.cs index c6962e2..7924224 100644 --- a/csharp/ncbo/ncbo/DataTypes/PageCollection.cs +++ b/csharp/ncbo/ncbo/DataTypes/PageCollection.cs @@ -7,6 +7,8 @@ namespace ncbo.DataTypes { public class PageCollection { + [JsonProperty("@id")] + public string ID { get; set; } [JsonProperty("prefLabel")] public string PrefLabel { get; set; } [JsonProperty("synonym")] @@ -20,6 +22,6 @@ public class PageCollection [JsonProperty("obsolete")] public bool Obsolete { get; set; } [JsonProperty("links")] - public PageLink Links { get; set; } -} + public PageLinks Links { get; set; } + } } diff --git a/csharp/ncbo/ncbo/DataTypes/PageLink.cs b/csharp/ncbo/ncbo/DataTypes/PageLink.cs index f939d5f..8f0aff8 100644 --- a/csharp/ncbo/ncbo/DataTypes/PageLink.cs +++ b/csharp/ncbo/ncbo/DataTypes/PageLink.cs @@ -5,7 +5,7 @@ namespace ncbo.DataTypes { - public class PageLink + public class PageLinks { [JsonProperty("nextPage")] public string NextPageUrl { get; set; } diff --git a/csharp/ncbo/ncbo/GetLabels.cs b/csharp/ncbo/ncbo/GetLabels.cs index b0b0f58..9eedf83 100644 --- a/csharp/ncbo/ncbo/GetLabels.cs +++ b/csharp/ncbo/ncbo/GetLabels.cs @@ -13,7 +13,7 @@ public static class GetLabels public static void DoIt() { // Get all ontologies from the REST service and parse the JSON - Ontology[] ontology = Network.GetResponseAs("http://data.bioontology.org/ontologies"); + Ontology[] ontology = Network.GetResponseAs(Constants.BaseUrl + "/ontologies"); Ontology broOntology = ontology.Where(n => n.Acronym == "BRO").FirstOrDefault(); diff --git a/csharp/ncbo/ncbo/Program.cs b/csharp/ncbo/ncbo/Program.cs index eba2720..78b8e8a 100644 --- a/csharp/ncbo/ncbo/Program.cs +++ b/csharp/ncbo/ncbo/Program.cs @@ -11,7 +11,9 @@ class Program { static void Main(string[] args) { - GetLabels.DoIt(); + //GetLabels.DoIt(); + + AnnotateText.DoIt(); } } } \ No newline at end of file From 8f655e41e25c73fc15865f4416e549b1f9f15753 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 16 Apr 2017 19:42:48 -0500 Subject: [PATCH 3/4] Classes search. --- csharp/ncbo/ncbo/ClassesSearch.cs | 35 +++++++++++++++++++++++++++++++ csharp/ncbo/ncbo/Program.cs | 4 +++- csharp/ncbo/ncbo/TextFile1.txt | 11 ---------- csharp/ncbo/ncbo/classes_search_terms.txt | 6 ++++++ csharp/ncbo/ncbo/ncbo.csproj | 2 +- 5 files changed, 45 insertions(+), 13 deletions(-) create mode 100644 csharp/ncbo/ncbo/ClassesSearch.cs delete mode 100644 csharp/ncbo/ncbo/TextFile1.txt create mode 100644 csharp/ncbo/ncbo/classes_search_terms.txt diff --git a/csharp/ncbo/ncbo/ClassesSearch.cs b/csharp/ncbo/ncbo/ClassesSearch.cs new file mode 100644 index 0000000..b5d28ed --- /dev/null +++ b/csharp/ncbo/ncbo/ClassesSearch.cs @@ -0,0 +1,35 @@ +using ncbo.Common; +using ncbo.DataTypes; +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace ncbo +{ + public static class ClassesSearch + { + public static void DoIt() + { + string[] lines = File.ReadAllLines("classes_search_terms.txt"); + + List allCollections = new List(); + foreach(string line in lines) + { + Page page = + Network.GetResponseAs("http://data.bioontology.org/search?q=" + line); + + foreach(PageCollection collection in page.Collections) + { + allCollections.Add(collection); + } + } + + foreach(PageCollection collection in allCollections) + { + Console.WriteLine(collection.ID); + } + return; + } + } +} diff --git a/csharp/ncbo/ncbo/Program.cs b/csharp/ncbo/ncbo/Program.cs index 78b8e8a..e3f6ca1 100644 --- a/csharp/ncbo/ncbo/Program.cs +++ b/csharp/ncbo/ncbo/Program.cs @@ -13,7 +13,9 @@ static void Main(string[] args) { //GetLabels.DoIt(); - AnnotateText.DoIt(); + //AnnotateText.DoIt(); + + ClassesSearch.DoIt(); } } } \ No newline at end of file diff --git a/csharp/ncbo/ncbo/TextFile1.txt b/csharp/ncbo/ncbo/TextFile1.txt deleted file mode 100644 index 470e6bc..0000000 --- a/csharp/ncbo/ncbo/TextFile1.txt +++ /dev/null @@ -1,11 +0,0 @@ -{"menu": { - "id": "file", - "value": "File", - "popup": { - "menuitem": [ - {"value": "New", "onclick": "CreateNewDoc()"}, - {"value": "Open", "onclick": "OpenDoc()"}, - {"value": "Close", "onclick": "CloseDoc()"} - ] - } -}} \ No newline at end of file diff --git a/csharp/ncbo/ncbo/classes_search_terms.txt b/csharp/ncbo/ncbo/classes_search_terms.txt new file mode 100644 index 0000000..3bfddd9 --- /dev/null +++ b/csharp/ncbo/ncbo/classes_search_terms.txt @@ -0,0 +1,6 @@ +heart +lung +experiment +human +brain +melanoma \ No newline at end of file diff --git a/csharp/ncbo/ncbo/ncbo.csproj b/csharp/ncbo/ncbo/ncbo.csproj index fb211d3..b248623 100644 --- a/csharp/ncbo/ncbo/ncbo.csproj +++ b/csharp/ncbo/ncbo/ncbo.csproj @@ -10,7 +10,7 @@ - + Always From 38994eb8d86ee2779d1f52e5d48cb93f058b7e99 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 16 Apr 2017 22:42:07 -0500 Subject: [PATCH 4/4] 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