r26152 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26151‎ | r26152 | r26153 >
Date:12:48, 26 September 2007
Author:proes
Status:old
Tags:
Comment:
Refactored bootstrapping of concepts.
Modified paths:
  • /trunk/extensions/Wikidata/php-tools/SwissProtImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/php-tools/SwissProtImport.php
@@ -53,6 +53,8 @@
5454
5555 function importEntriesFromXMLFile($fileHandle, $umlsCollectionId, $goCollection, $hugoCollection, $EC2GoMeaningIdMapping, $keyword2GoMeaningIdMapping, ProgressBar $progressBar) {
5656 $languageId = 85;
 57+ bootstrapCollection("concept mapping", $languageId, "MAPP");
 58+
5759 $collectionId = bootstrapCollection("Swiss-Prot", $languageId, "");
5860 $classCollectionId = bootstrapCollection("Swiss-Prot classes", $languageId, "CLAS");
5961 $relationTypeCollectionId = bootstrapCollection("Swiss-Prot relation types", $languageId, "RELT");
@@ -189,238 +191,98 @@
190192 protected $progressBar;
191193
192194 protected function bootstrapDefinedMeaning($spelling, $definition = null) {
193 - if (!isset( $definition ) ){
 195+ if (!isset($definition))
194196 $definition = $spelling;
195 - }
 197+
196198 $expression = $this->getOrCreateExpression($spelling);
197199 $definedMeaningId = createNewDefinedMeaning($expression->id, $this->languageId, $definition);
198200
199201 return $definedMeaningId;
200202 }
201203
 204+ protected function bootstrapConcept($conceptId, $spelling, $classId = 0) {
 205+ if ($conceptId == 0)
 206+ $conceptId = $this->bootstrapDefinedMeaning($spelling);
 207+
 208+ if ($classId != 0)
 209+ addClassMembership($conceptId, $classId);
 210+
 211+ return $conceptId;
 212+ }
 213+
202214 protected function bootstrapConceptIds() {
203 - if ($this->proteinConceptId == 0)
204 - $this->proteinConceptId = $this->bootstrapDefinedMeaning("amino acid, peptide, or protein");
 215+ $this->proteinConceptId = $this->bootstrapConcept($this->proteinConceptId, "protein");
 216+ $this->proteinFragmentConceptId = $this->bootstrapConcept($this->proteinFragmentConceptId, "protein fragment");
 217+ $this->organismSpecificProteinConceptId = $this->bootstrapConcept($this->organismSpecificProteinConceptId, "organism specific protein");
 218+ $this->organismSpecificGeneConceptId = $this->bootstrapConcept($this->organismSpecificGeneConceptId, "organism specific gene");
 219+ $this->geneConceptId = $this->bootstrapConcept($this->geneConceptId, "gene or genome");
 220+ $this->organismConceptId = $this->bootstrapConcept($this->organismConceptId, "organism");
 221+ $this->functionalDomainConceptId = $this->bootstrapConcept($this->functionalDomainConceptId, "functional domain");
 222+ $this->proteinComponentConceptId = $this->bootstrapConcept($this->proteinComponentConceptId, "protein component");
 223+ $this->biologicalProcessConceptId = $this->bootstrapConcept($this->biologicalProcessConceptId, "biological process");
 224+ $this->molecularFunctionConceptId = $this->bootstrapConcept($this->molecularFunctionConceptId, "molecular function");
 225+ $this->cellularComponentConceptId = $this->bootstrapConcept($this->cellularComponentConceptId, "cellular component");
 226+// $this->keywordConceptId = $this->bootstrapConcept($this->keywordConceptId, "keyword");
 227+ $this->enzymeCommissionNumberConceptId = $this->bootstrapConcept($this->enzymeCommissionNumberConceptId, "enzyme commission number");
205228
206 - if ($this->proteinFragmentConceptId == 0)
207 - $this->proteinFragmentConceptId = $this->bootstrapDefinedMeaning("protein fragment");
 229+ $this->textAttributeConceptId = $this->bootstrapConcept($this->textAttributeConceptId, "text attribute"); // TODO: Is this one necessary?
208230
209 - if ($this->organismSpecificProteinConceptId == 0)
210 - $this->organismSpecificProteinConceptId = $this->bootstrapDefinedMeaning("organism specific protein");
211 -
212 - if ($this->organismSpecificGeneConceptId == 0)
213 - $this->organismSpecificGeneConceptId = $this->bootstrapDefinedMeaning("organism specific gene");
214 -
215 - if ($this->geneConceptId == 0)
216 - $this->geneConceptId = $this->bootstrapDefinedMeaning("gene or genome");
217 -
218 - if ($this->organismConceptId == 0)
219 - $this->organismConceptId = $this->bootstrapDefinedMeaning("organism");
220 -
221 - if ($this->functionalDomainConceptId == 0)
222 - $this->functionalDomainConceptId = $this->bootstrapDefinedMeaning("functional domain");
223 -
224 - if ($this->proteinComponentConceptId == 0)
225 - $this->proteinComponentConceptId = $this->bootstrapDefinedMeaning("protein component");
226 -
227 - if ($this->biologicalProcessConceptId == 0)
228 - $this->biologicalProcessConceptId = $this->bootstrapDefinedMeaning("biological process");
229 -
230 - if ($this->molecularFunctionConceptId == 0)
231 - $this->molecularFunctionConceptId = $this->bootstrapDefinedMeaning("molecular function");
232 -
233 - if ($this->cellularComponentConceptId == 0)
234 - $this->cellularComponentConceptId = $this->bootstrapDefinedMeaning("cellular component");
235 -
236 -// if ($this->keywordConceptId == 0)
237 -// $this->keywordConceptId = $this->bootstrapDefinedMeaning("keyword");
238 -
239 - if ($this->enzymeCommissionNumberConceptId == 0)
240 - $this->enzymeCommissionNumberConceptId = $this->bootstrapDefinedMeaning("enzyme commission number");
241 -
242 - if ($this->textAttributeConceptId == 0)
243 - $this->textAttributeConceptId = $this->bootstrapDefinedMeaning("text attribute");
244 -
245231 // create root class for all defined meaning comment types
246 - if ($this->textAttributeClassId == 0)
247 - $this->textAttributeClassId = $this->bootstrapDefinedMeaning("text attribute class");
 232+ $this->textAttributeClassId = $this->bootstrapConcept($this->textAttributeClassId, "text attribute class"); // TODO: Is this one necessary?
248233
249234 // create top class for semantic comment types and link it to the root class
250 - if ($this->semanticGroupId == 0)
251 - $this->semanticGroupId = $this->bootstrapDefinedMeaning("Semantic Group");
252 - addClassMemberShip($this->semanticGroupId, $this->textAttributeClassId);
 235+ $this->semanticGroupId = $this->bootstrapConcept($this->semanticGroupId, "Semantic Group", $this->textAttributeClassId);
253236
254237 // define a different comment type aspects and link them with the comment top class
255 - if ($this->localizationAspectId == 0)
256 - $this->localizationAspectId = $this->bootstrapDefinedMeaning("Localization aspects");
257 - addClassMemberShip($this->localizationAspectId, $this->semanticGroupId);
 238+ $this->localizationAspectId = $this->bootstrapConcept($this->localizationAspectId, "Localization aspects", $this->semanticGroupId);
 239+ $this->functionalAspectId = $this->bootstrapConcept($this->functionalAspectId, "Functional aspects", $this->semanticGroupId);
 240+ $this->structuralAspectId = $this->bootstrapConcept($this->structuralAspectId, "Structural aspects", $this->semanticGroupId);
 241+ $this->pharmaceuticalAspectId = $this->bootstrapConcept($this->pharmaceuticalAspectId, "Pharmaceutical aspects", $this->semanticGroupId);
 242+ $this->externalInformationId = $this->bootstrapConcept($this->externalInformationId, "External information", $this->semanticGroupId);
 243+ $this->otherAspectId = $this->bootstrapConcept($this->otherAspectId, "Other aspects", $this->semanticGroupId);
 244+ $this->functionallyRelatedId = $this->bootstrapConcept($this->functionallyRelatedId, "Functionally related", $this->semanticGroupId);
 245+ $this->spatiallyRelatedId = $this->bootstrapConcept($this->spatiallyRelatedId, "Spatially related", $this->semanticGroupId);
 246+ $this->physicallyRelatedId = $this->bootstrapConcept($this->physicallyRelatedId, "Physically related", $this->semanticGroupId);
 247+ $this->temporallyRelatedId = $this->bootstrapConcept($this->temporallyRelatedId, "Temporally related", $this->semanticGroupId);
 248+ $this->terminologicallyRelatedId = $this->bootstrapConcept($this->terminologicallyRelatedId, "Terminologically related", $this->semanticGroupId);
 249+ $this->conceptuallyRelatedId = $this->bootstrapConcept($this->conceptuallyRelatedId, "Conceptually related", $this->semanticGroupId);
258250
259 - if ($this->functionalAspectId == 0)
260 - $this->functionalAspectId = $this->bootstrapDefinedMeaning("Functional aspects");
261 - addClassMemberShip($this->functionalAspectId, $this->semanticGroupId);
262 -
263 - if ($this->structuralAspectId == 0)
264 - $this->structuralAspectId = $this->bootstrapDefinedMeaning("Structural aspects");
265 - addClassMemberShip($this->structuralAspectId, $this->semanticGroupId);
266 -
267 - if ($this->pharmaceuticalAspectId == 0)
268 - $this->pharmaceuticalAspectId = $this->bootstrapDefinedMeaning("Pharmaceutical aspects");
269 - addClassMemberShip($this->pharmaceuticalAspectId, $this->semanticGroupId);
270 -
271 - if ($this->externalInformationId == 0)
272 - $this->externalInformationId = $this->bootstrapDefinedMeaning("External information");
273 - addClassMemberShip($this->externalInformationId, $this->semanticGroupId);
274 -
275 - if ($this->otherAspectId == 0)
276 - $this->otherAspectId = $this->bootstrapDefinedMeaning("Other aspects");
277 - addClassMemberShip($this->otherAspectId, $this->semanticGroupId);
278 -
279 - if ($this->functionallyRelatedId == 0)
280 - $this->functionallyRelatedId = $this->bootstrapDefinedMeaning("Functionally related");
281 - addClassMemberShip($this->functionallyRelatedId, $this->semanticGroupId);
282 -
283 - if ($this->spatiallyRelatedId == 0)
284 - $this->spatiallyRelatedId = $this->bootstrapDefinedMeaning("Spatially related");
285 - addClassMemberShip($this->spatiallyRelatedId, $this->semanticGroupId);
286 -
287 - if ($this->physicallyRelatedId == 0)
288 - $this->physicallyRelatedId = $this->bootstrapDefinedMeaning("Physically related");
289 - addClassMemberShip($this->physicallyRelatedId, $this->semanticGroupId);
290 -
291 - if ($this->temporallyRelatedId == 0)
292 - $this->temporallyRelatedId = $this->bootstrapDefinedMeaning("Temporally related");
293 - addClassMemberShip($this->temporallyRelatedId, $this->semanticGroupId);
294 -
295 - if ($this->terminologicallyRelatedId == 0)
296 - $this->terminologicallyRelatedId = $this->bootstrapDefinedMeaning("Terminologically related");
297 - addClassMemberShip($this->terminologicallyRelatedId, $this->semanticGroupId);
298 -
299 - if ($this->conceptuallyRelatedId == 0)
300 - $this->conceptuallyRelatedId = $this->bootstrapDefinedMeaning("Conceptually related");
301 - addClassMemberShip($this->conceptuallyRelatedId, $this->semanticGroupId);
 251+ // some relations and their super class
 252+ $this->activityConceptId = $this->bootstrapConcept($this->activityConceptId, "performs", $this->functionallyRelatedId);
 253+ $this->containsConceptId = $this->bootstrapConcept($this->containsConceptId, "contains", $this->functionallyRelatedId);
 254+ $this->includesConceptId = $this->bootstrapConcept($this->includesConceptId, "consists of", $this->physicallyRelatedId);
302255
303 - // some relation and there supper class
304 - if ($this->activityConceptId == 0)
305 - $this->activityConceptId = $this->bootstrapDefinedMeaning("performs");
306 - addClassMemberShip($this->activityConceptId, $this->functionallyRelatedId);
307 -
308 - if ($this->containsConceptId == 0)
309 - $this->containsConceptId = $this->bootstrapDefinedMeaning("contains");
310 - addClassMemberShip($this->containsConceptId, $this->functionallyRelatedId);
 256+ // assign each comment type to one type aspect (later perhaps to multiple aspects)
 257+ $this->subcellularLocationId = $this->bootstrapConcept($this->subcellularLocationId, "subcellular location", $this->localizationAspectId);
 258+ $this->tissueSpecificityId = $this->bootstrapConcept($this->tissueSpecificityId, "tissue specificity", $this->localizationAspectId);
 259+ $this->catalyticActivityId = $this->bootstrapConcept($this->catalyticActivityId, "catalytic activity", $this->functionalAspectId);
 260+ $this->cofactorId = $this->bootstrapConcept($this->cofactorId, "cofactor", $this->functionalAspectId);
 261+ $this->functionId = $this->bootstrapConcept($this->functionId, "function", $this->functionalAspectId);
 262+ $this->diseaseId = $this->bootstrapConcept($this->diseaseId, "disease", $this->functionalAspectId);
 263+ $this->enzymeRegulationId = $this->bootstrapConcept($this->enzymeRegulationId, "enzyme regulation", $this->functionalAspectId);
 264+ $this->inductionId = $this->bootstrapConcept($this->inductionId, "induction", $this->functionalAspectId);
 265+ $this->interactionId = $this->bootstrapConcept($this->interactionId, "interaction", $this->functionalAspectId);
 266+ $this->pathwayId = $this->bootstrapConcept($this->pathwayId, "pathway", $this->functionalAspectId);
 267+ $this->rnaEditingId = $this->bootstrapConcept($this->rnaEditingId, "RNA editing", $this->functionalAspectId);
311268
312 - if ($this->includesConceptId == 0)
313 - $this->includesConceptId = $this->bootstrapDefinedMeaning("consists of");
314 - addClassMemberShip($this->includesConceptId, $this->physicallyRelatedId);
 269+ $this->alternativeProductsId = $this->bootstrapConcept($this->alternativeProductsId, "alternative products", $this->structuralAspectId);
 270+ $this->domainId = $this->bootstrapConcept($this->domainId, "domain", $this->structuralAspectId);
 271+ $this->ptmId = $this->bootstrapConcept($this->ptmId, "PTM", $this->structuralAspectId);
 272+ $this->polymorphismId = $this->bootstrapConcept($this->polymorphismId, "polymorphism", $this->structuralAspectId);
 273+ $this->similarityId = $this->bootstrapConcept($this->similarityId, "similarity", $this->structuralAspectId);
 274+ $this->massSpectrometryId = $this->bootstrapConcept($this->massSpectrometryId, "mass spectometry", $this->structuralAspectId);
 275+ $this->subunitId = $this->bootstrapConcept($this->subunitId, "subunit", $this->structuralAspectId);
315276
316 - // assign each comment type to one type aspect (later perhaps to multiple aspects)
317 - if ($this->subcellularLocationId == 0){
318 - $this->subcellularLocationId = $this->bootstrapDefinedMeaning("SUBCELLULAR LOCATION");
319 - addClassMemberShip($this->subcellularLocationId, $this->localizationAspectId);
320 - }
321 - if ($this->tissueSpecificityId == 0){
322 - $this->tissueSpecificityId = $this->bootstrapDefinedMeaning("TISSUE SPECIFICITY");
323 - addClassMemberShip($this->tissueSpecificityId, $this->localizationAspectId);
324 - }
325 - if ($this->catalyticActivityId == 0){
326 - $this->catalyticActivityId = $this->bootstrapDefinedMeaning("CATALYTIC ACTIVITY");
327 - addClassMemberShip($this->catalyticActivityId, $this->functionalAspectId);
328 - }
329 - if ($this->cofactorId == 0){
330 - $this->cofactorId = $this->bootstrapDefinedMeaning("COFACTOR");
331 - addClassMemberShip($this->cofactorId, $this->functionalAspectId);
332 - }
333 - if ($this->functionId == 0){
334 - $this->functionId = $this->bootstrapDefinedMeaning("FUNCTION");
335 - addClassMemberShip($this->functionId, $this->functionalAspectId);
336 - }
337 - if ($this->diseaseId == 0){
338 - $this->diseaseId = $this->bootstrapDefinedMeaning("DISEASE");
339 - addClassMemberShip($this->diseaseId, $this->functionalAspectId);
340 - }
341 - if ($this->enzymeRegulationId == 0){
342 - $this->enzymeRegulationId = $this->bootstrapDefinedMeaning("ENZYME REGULATION");
343 - addClassMemberShip($this->enzymeRegulationId, $this->functionalAspectId);
344 - }
345 - if ($this->inductionId == 0){
346 - $this->inductionId = $this->bootstrapDefinedMeaning("INDUCTION");
347 - addClassMemberShip($this->inductionId, $this->functionalAspectId);
348 - }
349 - if ($this->interactionId == 0){
350 - $this->interactionId = $this->bootstrapDefinedMeaning("INTERACTION");
351 - addClassMemberShip($this->interactionId, $this->functionalAspectId);
352 - }
353 - if ($this->pathwayId == 0){
354 - $this->pathwayId = $this->bootstrapDefinedMeaning("PATHWAY");
355 - addClassMemberShip($this->pathwayId, $this->functionalAspectId);
356 - }
357 - if ($this->rnaEditingId == 0){
358 - $this->rnaEditingId = $this->bootstrapDefinedMeaning("RNA EDITING");
359 - addClassMemberShip($this->rnaEditingId, $this->functionalAspectId);
360 - }
361 - if ($this->alternativeProductsId == 0){
362 - $this->alternativeProductsId = $this->bootstrapDefinedMeaning("ALTERNATIVE PRODUCTS");
363 - addClassMemberShip($this->alternativeProductsId, $this->structuralAspectId);
364 - }
365 - if ($this->domainId == 0){
366 - $this->domainId = $this->bootstrapDefinedMeaning("DOMAIN");
367 - addClassMemberShip($this->domainId, $this->structuralAspectId);
368 - }
369 - if ($this->ptmId == 0){
370 - $this->ptmId = $this->bootstrapDefinedMeaning("PTM");
371 - addClassMemberShip($this->ptmId, $this->structuralAspectId);
372 - }
373 - if ($this->polymorphismId == 0){
374 - $this->polymorphismId = $this->bootstrapDefinedMeaning("POLYMORPHISM");
375 - addClassMemberShip($this->polymorphismId, $this->structuralAspectId);
376 - }
377 - if ($this->similarityId == 0){
378 - $this->similarityId = $this->bootstrapDefinedMeaning("SIMILARITY");
379 - addClassMemberShip($this->similarityId, $this->structuralAspectId);
380 - }
381 - if ($this->massSpectrometryId == 0){
382 - $this->massSpectrometryId = $this->bootstrapDefinedMeaning("MASS SPECTROMETRY");
383 - addClassMemberShip($this->massSpectrometryId, $this->structuralAspectId);
384 - }
385 - if ($this->subunitId == 0){
386 - $this->subunitId = $this->bootstrapDefinedMeaning("SUBUNIT");
387 - addClassMemberShip($this->subunitId, $this->structuralAspectId);
388 - }
389 - if ($this->allergenId == 0){
390 - $this->allergenId = $this->bootstrapDefinedMeaning("ALLERGEN");
391 - addClassMemberShip($this->allergenId, $this->pharmaceuticalAspectId);
392 - }
393 - if ($this->pharmaceuticalId == 0){
394 - $this->pharmaceuticalId = $this->bootstrapDefinedMeaning("PHARMACEUTICAL");
395 - addClassMemberShip($this->pharmaceuticalId, $this->pharmaceuticalAspectId);
396 - }
397 - if ($this->biotechnologyId == 0){
398 - $this->biotechnologyId = $this->bootstrapDefinedMeaning("BIOTECHNOLOGY");
399 - addClassMemberShip($this->biotechnologyId, $this->pharmaceuticalAspectId);
400 - }
401 - if ($this->toxicDoseId == 0){
402 - $this->toxicDoseId = $this->bootstrapDefinedMeaning("TOXIC DOSE");
403 - addClassMemberShip($this->toxicDoseId, $this->pharmaceuticalAspectId);
404 - }
405 - if ($this->biophysicochemicalPropertiesId == 0){
406 - $this->biophysicochemicalPropertiesId = $this->bootstrapDefinedMeaning("BIOPHYSICOCHEMICAL PROPERTIES");
407 - addClassMemberShip($this->biophysicochemicalPropertiesId, $this->pharmaceuticalAspectId);
408 - }
409 - if ($this->onlineInformationId == 0){
410 - $this->onlineInformationId = $this->bootstrapDefinedMeaning("ONLINE INFORMATION");
411 - addClassMemberShip($this->onlineInformationId, $this->externalInformationId);
412 - }
413 - if ($this->developmentalStageId == 0){
414 - $this->developmentalStageId = $this->bootstrapDefinedMeaning("DEVELOPMENTAL STAGE");
415 - addClassMemberShip($this->developmentalStageId, $this->otherAspectId);
416 - }
417 - if ($this->miscellaneousId == 0){
418 - $this->miscellaneousId = $this->bootstrapDefinedMeaning("MISCELLANEOUS");
419 - addClassMemberShip($this->miscellaneousId, $this->otherAspectId);
420 - }
421 - if ($this->cautionId == 0){
422 - $this->cautionId = $this->bootstrapDefinedMeaning("CAUTION");
423 - addClassMemberShip($this->cautionId, $this->otherAspectId);
424 - }
 277+ $this->allergenId = $this->bootstrapConcept($this->allergenId, "allergen", $this->pharmaceuticalAspectId);
 278+ $this->pharmaceuticalId = $this->bootstrapConcept($this->pharmaceuticalId, "pharmaceutical", $this->pharmaceuticalAspectId);
 279+ $this->biotechnologyId = $this->bootstrapConcept($this->biotechnologyId, "biotechnology", $this->pharmaceuticalAspectId);
 280+ $this->toxicDoseId = $this->bootstrapConcept($this->toxicDoseId, "toxic dose", $this->pharmaceuticalAspectId);
 281+ $this->biophysicochemicalPropertiesId = $this->bootstrapConcept($this->biophysicochemicalPropertiesId, "biophysicochemical properties", $this->pharmaceuticalAspectId);
 282+
 283+ $this->onlineInformationId = $this->bootstrapConcept($this->onlineInformationId, "online information", $this->externalInformationId);
 284+ $this->developmentalStageId = $this->bootstrapConcept($this->developmentalStageId, "developmental stage", $this->otherAspectId);
 285+ $this->miscellaneousId = $this->bootstrapConcept($this->miscellaneousId, "miscellaneous", $this->otherAspectId);
 286+ $this->cautionId = $this->bootstrapConcept($this->cautionId, "caution", $this->otherAspectId);
425287 }
426288
427289 public function setProgressBar(ProgressBar $progressBar) {

Status & tagging log