Changeset 439 for trunk/test
- Timestamp:
- May 19, 2010, 4:36:21 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/integration/gscf/OntologyTests.groovy
r425 r439 4 4 import dbnp.data.* 5 5 6 import uk.ac.ebi.ontocat.* 6 7 7 8 /** … … 68 69 } 69 70 70 71 71 /** 72 * Test saving and retrieving a term within the ontology and test giveTermByName(name) 72 * Test saving and retrieving a term within the ontology and test giveTermByName(name) and giveTerms() 73 73 */ 74 74 void testTermSave() { … … 93 93 assert termDB.accession.equals(testAccession) 94 94 assert termDB.ontology == testOntology 95 }96 95 97 98 /** 99 * Test giveTerms() method 100 */ 101 void testGiveTerms() { 102 103 // Find created ontology 104 def testOntology = Ontology.findByName(testOntologyName) 105 assert testOntology 106 96 // Test giveTerms() and make sure the term is in there 107 97 def terms = testOntology.giveTerms() 108 98 assert terms … … 111 101 } 112 102 103 /** 104 * Ontocat test for debug purposes: show all properties of a certain ontology 105 */ 106 private void testOntocatBioPortalDebug() { 107 // Instantiate OLS service 108 uk.ac.ebi.ontocat.OntologyService os = new uk.ac.ebi.ontocat.bioportal.BioportalOntologyService() 109 110 // Find ontology by ncboId 111 uk.ac.ebi.ontocat.Ontology o = os.getOntology("1005") 112 StringBuilder sb = new StringBuilder(); 113 def bean = os.getOntologyBean() 114 String codingScheme = bean.codingScheme 115 sb.append("OntologyBean:\n") 116 sb.append("property codingScheme="+codingScheme+"\n") 117 sb.append("Bean.properties:\n") 118 bean.properties.each { 119 sb.append(it.key + "=" + it.value+"\n") 120 } 121 sb.append "Bean:\t" + bean.dump() 122 sb.append(bean.properties['codingScheme']) 123 sb.append("\t"); 124 sb.append(o.getAbbreviation()); 125 sb.append("\t"); 126 sb.append(o.getLabel()); 127 sb.append("\t"); 128 sb.append(o.getOntologyAccession()); 129 sb.append("\t"); 130 sb.append("Ontology meta properties:\n") 131 o.getVersionNumber() + o.getMetaPropertyValues().each { 132 sb.append(it.name + "=" + it.value+"\n") 133 } 134 sb.append("Ontology properties:\n"); 135 o.getProperties().each { 136 sb.append(it.key + "=" + it.value+"\n") 137 } 138 sb.append("Ontology root terms:\n"); 139 os.getRootTerms(o).each { 140 sb.append("Term ${os.makeLookupHyperlink(it.properties.get('accession'))} properties:\n") 141 it.properties.each { 142 sb.append it.key + "=" + it.value + "\n" 143 } 144 } 145 System.out.println(sb.toString()); 146 } 113 147 114 148 /** 115 * Ontocat test (Ontocat example 1) 116 * 117 * Shows how to list all the available ontologies in OLS 118 * 119 */ 120 void testOntocat() { 121 // Instantiate OLS service 122 uk.ac.ebi.ontocat.OntologyService os = new uk.ac.ebi.ontocat.bioportal.BioportalOntologyService() 123 // For all ontologies in OLS print their 124 // full label and abbreviation 125 uk.ac.ebi.ontocat.Ontology o = os.getOntology("1005") 126 StringBuilder sb = new StringBuilder(); 127 sb.append(o.getAbbreviation()); 128 sb.append("\t"); 129 sb.append(o.getLabel()); 130 sb.append("\t"); 131 sb.append(o.getOntologyAccession()); 132 sb.append("\t"); 133 o.getVersionNumber() + o.getMetaPropertyValues().each { 134 sb.append(it.dump()) 135 } 136 System.out.println(sb.toString()); 137 149 * Add all OLS ontologies to the database via the Ontocat framework 150 */ 151 void testOntocatOLSOntologies() { 152 // Instantiate EBI OLS service 153 uk.ac.ebi.ontocat.OntologyService os = new uk.ac.ebi.ontocat.ols.OlsOntologyService() 154 addOntologies(os) 138 155 } 139 156 157 /** 158 * Add all BioPortal ontologies to the database via the Ontocat framework 159 */ 160 void testOntocatBioPortalOntologies() { 161 // Instantiate BioPortal service 162 uk.ac.ebi.ontocat.OntologyService os = new uk.ac.ebi.ontocat.bioportal.BioportalOntologyService() 163 addOntologies(os) 164 } 165 166 private void addOntologies(uk.ac.ebi.ontocat.OntologyService os) { 167 168 // Iterate over all ontologies in OLS 169 os.getOntologies().each { 170 171 // Get bean and extract versionedId 172 def bean = os.ontologyBean 173 def matcher = bean.codingScheme =~ "/(\\d{5})/" 174 assert matcher 175 assert matcher.size() == 1 176 assert matcher[0].size() == 2 177 def versionedId = matcher[0][1] 178 179 // Instantiate ontology 180 def ontology = new Ontology( 181 name: o.label, 182 description: o.description, 183 url: bean.properties['homepage'], 184 //url: 'http://bioportal.bioontology.org/ontologies/' + versionedId, 185 versionNumber: o.versionNumber, 186 ncboId: o.ontologyAccession, 187 ncboVersionedId: versionedId 188 ); 189 190 // Validate and save ontology 191 assert ontology.validate() 192 assert ontology.save(flush:true) 193 194 //println ontology.dump() 195 } 196 } 197 } 140 198 }
Note: See TracChangeset
for help on using the changeset viewer.