r16296 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r16295‎ | r16296 | r16297 >
Date:11:42, 31 August 2006
Author:proes
Status:old
Tags:
Comment:
UMLS and SP import
Modified paths:
  • /trunk/extensions/Wikidata/WP/2GoMappingImport.php (modified) (history)
  • /trunk/extensions/Wikidata/WP/DataImport.php (modified) (history)
  • /trunk/extensions/Wikidata/WP/ProgressBar.php (modified) (history)
  • /trunk/extensions/Wikidata/WP/SwissProtImport.php (modified) (history)
  • /trunk/extensions/Wikidata/WP/UMLSImport.php (modified) (history)
  • /trunk/extensions/Wikidata/WP/XMLImport.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/WP/ProgressBar.php
@@ -1,7 +1,7 @@
22 <?php
33
44 global
5 - $beginTime;
 5+ $beginTime, $progressBarMaximum, $progressBarCurrent, $lastTimeDisplayed, $lastProgressDisplayed, $progressBarRefreshRate;
66
77 function durationToString($seconds) {
88 $hours = floor($seconds / 3600);
@@ -12,26 +12,57 @@
1313 return str_pad($hours, 2, "0", STR_PAD_LEFT) .":". str_pad($minutes, 2, "0", STR_PAD_LEFT) .":". str_pad($seconds, 2, "0", STR_PAD_LEFT);
1414 }
1515
16 -function progressBar($current, $maximum) {
 16+function initializeProgressBar($maximum, $refreshRate) {
 17+ global
 18+ $progressBarMaximum, $progressBarCurrent, $lastProgressDisplayed, $progressBarRefreshRate;
 19+
 20+ $progressBarMaximum = $maximum;
 21+ $progressBarCurrent = 0;
 22+ $lastProgressDisplayed = 0;
 23+ $progressBarRefreshRate = $refreshRate;
 24+
 25+ displayProgressBar();
 26+}
 27+
 28+function displayProgressBar() {
1729 global
18 - $beginTime;
 30+ $beginTime, $progressBarMaximum, $progressBarCurrent, $lastTimeDisplayed, $lastProgressDisplayed, $progressBarRefreshRate;
1931
20 - $timeElapsed = time() - $beginTime;
21 - $barWidth = 45;
22 -
23 - if ($maximum > 0) {
24 - $percentage = floor(100 * $current / $maximum);
25 - $barFull = floor($barWidth * $current / $maximum);
26 - }
27 - else {
28 - $percentage = 100;
29 - $barFull = $barWidth;
 32+ if ($progressBarCurrent == 0 || $progressBarCurrent >= $lastProgressDisplayed + $progressBarRefreshRate) {
 33+ $lastProgressDisplayed = $progressBarCurrent;
 34+ $timeElapsed = time() - $beginTime;
 35+ $barWidth = 45;
 36+
 37+ if ($progressBarMaximum > 0) {
 38+ $percentage = floor(100 * $progressBarCurrent / $progressBarMaximum);
 39+ $barFull = floor($barWidth * $progressBarCurrent / $progressBarMaximum);
 40+ }
 41+ else {
 42+ $percentage = 100;
 43+ $barFull = $barWidth;
 44+ }
 45+
 46+ echo "\r " . str_pad($percentage, 3, " ", STR_PAD_LEFT) . "% of $progressBarMaximum [". str_repeat("=", $barFull) . str_repeat(" ", $barWidth - $barFull) .
 47+ "] " . durationToString($timeElapsed);
3048 }
31 -
32 - echo "\r " . str_pad($percentage, 3, " ", STR_PAD_LEFT) . "% of $maximum [". str_repeat("=", $barFull) . str_repeat(" ", $barWidth - $barFull) .
33 - "] " . durationToString($timeElapsed);
3449 }
3550
 51+function advanceProgressBar($amount) {
 52+ global
 53+ $progressBarCurrent;
 54+
 55+ $progressBarCurrent += $amount;
 56+ displayProgressBar();
 57+}
 58+
 59+function setProgressBarPosition($position) {
 60+ global
 61+ $progressBarCurrent;
 62+
 63+ $progressBarCurrent = $position;
 64+ displayProgressBar();
 65+}
 66+
3667 function clearProgressBar() {
3768 echo "\r" . str_repeat(" ", 79) . "\r";
3869 }
Index: trunk/extensions/Wikidata/WP/UMLSImport.php
@@ -3,9 +3,6 @@
44 require_once("../../../LocalSettings.php");
55 require_once("../WiktionaryZ/Expression.php");
66
7 -// Uncomment following line for versioning support
8 -require_once("../WiktionaryZ/Transaction.php");
9 -
107 require_once("ProgressBar.php");
118 require_once("Setup.php");
129
@@ -14,14 +11,14 @@
1512 public $sourceAbbreviations = array();
1613 }
1714
18 -function importUMLSFromDatabase($server, $databaseName, $userName, $password) {
 15+/*
 16+ * Import UMLS entirely. Be sure to have started a transaction first!
 17+ */
 18+function importUMLSFromDatabase($server, $databaseName, $userName, $password, $sources = null) {
1919 $result = new UMLSImportResult;
2020
2121 openDatabase($server, $databaseName, $userName, $password);
2222
23 - // Uncomment following line for versioning support
24 - startNewTransaction(0, 0, "UMLS Import");
25 -
2623 $languageId = 85;
2724 echo "Creating UMLS collections\n";
2825 $umlsCollectionId = bootstrapCollection("UMLS", $languageId, "");
@@ -37,7 +34,7 @@
3835 addDefinedMeaningToCollection(getCollectionMeaningId($semanticNetworkRelationTypesCollectionId), $umlsCollectionId, "RL");
3936
4037 echo "Loading source abbreviations\n";
41 - $sourceAbbreviations = loadSourceAbbreviations();
 38+ $sourceAbbreviations = loadSourceAbbreviations($sources);
4239
4340 echo "Loading languages\n";
4441 $isoLanguages = loadIsoLanguages();
@@ -45,15 +42,21 @@
4643 echo "Importing UMLS terms per source\n";
4744 $i = 1;
4845 foreach ($sourceAbbreviations as $sab => $source) {
49 -// if($sab == "ICPC" || $sab == "SRC" || $sab == "GO" || $sab == "NCI") {
50 - $collectionId = bootstrapCollection($source, $languageId, "");
51 - $result->sourceAbbreviations[$sab] = $collectionId;
52 - clearProgressBar();
53 - importUMLSTerms($i, $source, $sab, $umlsCollectionId, $collectionId, $languageId, $isoLanguages);
54 - $i++;
55 -// }
 46+ $collectionId = bootstrapCollection($source, $languageId, "");
 47+ $result->sourceAbbreviations[$sab] = $collectionId;
 48+ echo " $i: $sab - $source\n";
 49+ importUMLSTerms($sab, $umlsCollectionId, $collectionId, $languageId, $isoLanguages);
 50+ $i++;
5651 }
5752
 53+ echo "Importing UMLS definitions per source\n";
 54+ $i = 1;
 55+ foreach ($sourceAbbreviations as $sab => $source) {
 56+ echo " $i: $sab - $source\n";
 57+ importUMLSDefinitions($sab, $umlsCollectionId, $result->sourceAbbreviations[$sab], $languageId);
 58+ $i++;
 59+ }
 60+
5861 echo "Importing UMLS relation types\n";
5962 importUMLSRelationTypes($relationCollectionId, $languageId);
6063
@@ -63,17 +66,17 @@
6467 echo "Importing UMLS relations per source\n";
6568 $relationCollection = getCollectionContents($relationCollectionId);
6669 $relationAttributesCollection = getCollectionContents($relationAttributesCollectionId);
67 - $i = 0;
 70+ $i = 1;
6871
6972 foreach ($sourceAbbreviations as $sab => $source) {
70 -// if($sab == "ICPC" || $sab == "GO" || $sab == "NCI") {
71 - echo " $i: $source\n";
72 - $query = "select cui1, cui2, rel from MRREL where sab like '$sab'";
73 - importUMLSRelations($umlsCollectionId , $relationCollection, $query);
74 - $query = "select cui1, cui2, rela from MRREL where sab like '$sab' and rela!=''";
75 - importUMLSRelations($umlsCollectionId , $relationAttributesCollection, $query);
76 - $i++;
77 -// }
 73+ echo " $i: $sab - $source\n";
 74+
 75+ $query = "select cui1, cui2, rel from MRREL where sab like '$sab'";
 76+ importUMLSRelations($umlsCollectionId , $relationCollection, $query);
 77+
 78+ $query = "select cui1, cui2, rela from MRREL where sab like '$sab' and rela!=''";
 79+ importUMLSRelations($umlsCollectionId , $relationAttributesCollection, $query);
 80+ $i++;
7881 }
7982
8083 echo "Importing semantic network types\n";
@@ -88,10 +91,8 @@
8992 $attributeTypes = getCollectionContents($semanticNetworkSemanticTypesCollectionId);
9093 $i = 1;
9194 foreach ($sourceAbbreviations as $sab => $source) {
92 -// if($sab == "ICPC" || $sab == "GO" || $sab == "NCI") {
93 - echo " " . $i++ . ": $source\n";
94 - importUMLSSemanticTypes($sab, $umlsCollectionId, $attributeTypes);
95 -// }
 95+ echo " " . $i++ . ": $sab - $source\n";
 96+ importUMLSSemanticTypes($sab, $umlsCollectionId, $attributeTypes);
9697 }
9798
9899 return $result;
@@ -119,33 +120,44 @@
120121 return $languages;
121122 }
122123
123 -function loadSourceAbbreviations() {
 124+function loadSourceAbbreviations($sources = null) {
124125 global
125126 $db;
126127
127128 $sourceAbbreviations = array();
128129 $queryResult = mysql_query("select RSAB, SON from MRSAB", $db);
129130
130 - while ($sab = mysql_fetch_object($queryResult)) {
131 - $sourceAbbreviations[$sab->RSAB] = $sab->SON;
132 - }
 131+ while ($sab = mysql_fetch_object($queryResult))
 132+ if ($sources == null || in_array($sab->RSAB, $sources))
 133+ $sourceAbbreviations[$sab->RSAB] = str_replace('_', '-', $sab->SON);
133134
134135 mysql_free_result($queryResult);
135136
136137 return $sourceAbbreviations;
137138 }
138139
139 -function importUMLSTerms($index, $name, $sab, $umlsCollectionId, $sourceCollectionId, $languageId, $isoLanguages) {
 140+function getSourceName($sourceAbbreviation) {
140141 global
141142 $db;
142143
143 - $queryResult = mysql_query("select str, cui, lat, code from MRCONSO where sab like '$sab'", $db);
144 - $rowCount = mysql_num_rows($queryResult);
 144+ $sourceAbbreviations = array();
 145+ $queryResult = mysql_query("select SON from MRSAB WHERE RSAB='$source'", $db);
145146
146 - echo " $index: $name ($rowCount)\n";
147 - $i = 0;
148 - progressBar(0, $rowCount);
 147+ $sab = mysql_fetch_object($queryResult);
 148+ $result = $sab->SON;
 149+
 150+ mysql_free_result($queryResult);
 151+
 152+ return $result;
 153+}
149154
 155+function importUMLSTerms($sab, $umlsCollectionId, $sourceCollectionId, $languageId, $isoLanguages) {
 156+ global
 157+ $db;
 158+
 159+ $queryResult = mysql_query("select str, cui, lat, code from MRCONSO where sab like '$sab'", $db);
 160+ initializeProgressBar(mysql_num_rows($queryResult), 100);
 161+
150162 $collectionMeaningId = getCollectionMeaningId($sourceCollectionId);
151163
152164 while ($umlsTerm = mysql_fetch_object($queryResult)) {
@@ -157,26 +169,51 @@
158170 addDefinedMeaningToCollection($definedMeaningId, $umlsCollectionId, $umlsTerm->cui);
159171 }
160172 $expression->assureIsBoundToDefinedMeaning($definedMeaningId, true);
161 - $definitionQueryResult = mysql_query("select def, sab from MRDEF where sab = '$sab' and cui='$umlsTerm->cui'", $db);
162 - if($definition = mysql_fetch_object($definitionQueryResult)) {
163 - if(!getDefinedMeaningDefinitionId($definedMeaningId)) {
 173+// $definitionQueryResult = mysql_query("select def, sab from MRDEF where sab = '$sab' and cui='$umlsTerm->cui'", $db);
 174+// if($definition = mysql_fetch_object($definitionQueryResult)) {
 175+// if(!getDefinedMeaningDefinitionId($definedMeaningId)) {
 176+// addDefinedMeaningDefiningDefinition($definedMeaningId, $languageId, $definition->def);
 177+// }
 178+// addDefinedMeaningAlternativeDefinition($definedMeaningId, $languageId, $definition->def, $collectionMeaningId);
 179+//
 180+// while ($definition = mysql_fetch_object($definitionQueryResult)) {
 181+// addDefinedMeaningAlternativeDefinition($definedMeaningId, $languageId, $definition->def, $collectionMeaningId);
 182+// }
 183+// }
 184+// mysql_free_result($definitionQueryResult);
 185+
 186+ addDefinedMeaningToCollectionIfNotPresent($definedMeaningId, $sourceCollectionId, $umlsTerm->code);
 187+ advanceProgressBar(1);
 188+ }
 189+
 190+ mysql_free_result($queryResult);
 191+ clearProgressBar();
 192+}
 193+
 194+function importUMLSDefinitions($sab, $umlsCollectionId, $sourceCollectionId, $languageId) {
 195+ global
 196+ $db;
 197+
 198+ $queryResult = mysql_query("select def, cui from MRDEF where sab = '$sab'", $db);
 199+ initializeProgressBar(mysql_num_rows($queryResult), 100);
 200+
 201+ $collectionMeaningId = getCollectionMeaningId($sourceCollectionId);
 202+
 203+ while ($definition = mysql_fetch_object($queryResult)) {
 204+ $definedMeaningId = getDefinedMeaningFromCollection($umlsCollectionId, $definition->cui);
 205+
 206+ if($definedMeaningId) {
 207+ if(!getDefinedMeaningDefinitionId($definedMeaningId))
164208 addDefinedMeaningDefiningDefinition($definedMeaningId, $languageId, $definition->def);
165 - }
 209+
166210 addDefinedMeaningAlternativeDefinition($definedMeaningId, $languageId, $definition->def, $collectionMeaningId);
167 -
168 - while ($definition = mysql_fetch_object($definitionQueryResult)) {
169 - addDefinedMeaningAlternativeDefinition($definedMeaningId, $languageId, $definition->def, $collectionMeaningId);
170 - }
171211 }
172 - mysql_free_result($definitionQueryResult);
173 -
174 - addDefinedMeaningToCollectionIfNotPresent($definedMeaningId, $sourceCollectionId, $umlsTerm->code);
175 - $i++;
176212
177 - if ($i % 50 == 0)
178 - progressBar($i, $rowCount);
 213+ advanceProgressBar(1);
179214 }
180 - mysql_free_result($queryResult);
 215+
 216+ mysql_free_result($queryResult);
 217+ clearProgressBar();
181218 }
182219
183220 function importUMLSRelationTypes($relationCollectionId, $languageId) {
@@ -220,6 +257,8 @@
221258 $db;
222259
223260 $queryResult = mysql_query($query, $db);
 261+ initializeProgressBar(mysql_num_rows($queryResult), 100);
 262+
224263 while ($relation = mysql_fetch_row($queryResult)) {
225264 $relationType = $relation[2];
226265 if(strcmp($relationType, 'CHD') == 0) {
@@ -245,8 +284,11 @@
246285 print_r($relationCollectionContents);
247286 print_r($relation);
248287 }
249 - addRelation($definedMeaningId2, $relationMeaningId, $definedMeaningId1);
 288+ addRelation($definedMeaningId2, $relationMeaningId, $definedMeaningId1);
 289+ advanceProgressBar(1);
250290 }
 291+
 292+ clearProgressBar();
251293 }
252294
253295 function importSNTypes($collectionId, $query, $languageId) {
@@ -303,6 +345,9 @@
304346
305347 $query = "SELECT MRSTY.CUI, MRSTY.STY FROM MRCONSO,MRSTY where MRCONSO.SAB like '$sab' and MRCONSO.CUI=MRSTY.CUI";
306348 $queryResult = mysql_query($query, $db);
 349+
 350+ initializeProgressBar(mysql_num_rows($queryResult), 100);
 351+
307352 while ($attribute = mysql_fetch_object($queryResult)) {
308353 $definedMeaningId = getDefinedMeaningFromCollection($collectionId, $attribute->CUI);
309354 $attributeMeaningId = $attributeTypes[$attribute->STY];
@@ -315,8 +360,11 @@
316361 echo "Unknown attribute $attribute->STY\n";
317362 print_r($attribute);
318363 }
319 - addRelation($definedMeaningId, 0, $attributeMeaningId);
320 - }
 364+ addClassMembership($definedMeaningId, $attributeMeaningId);
 365+ advanceProgressBar(1);
 366+ }
 367+
 368+ clearProgressBar();
321369 }
322370
323371 ?>
Index: trunk/extensions/Wikidata/WP/XMLImport.php
@@ -1,7 +1,5 @@
22 <?php
33
4 -require_once("ProgressBar.php");
5 -
64 $depth = array();
75 $specificXMLParser;
86
Index: trunk/extensions/Wikidata/WP/2GoMappingImport.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -function importEC2GoMapping($fileName) {
 4+function loadEC2GoMapping($fileName) {
55 $mapping=array();
66 $fileHandle = fopen($fileName, "r");
77
@@ -31,7 +31,7 @@
3232 return $mapping;
3333 }
3434
35 -function importSwissProtKeyWord2GoMapping($fileName) {
 35+function loadSwissProtKeyWord2GoMapping($fileName) {
3636 $mapping=array();
3737 $fileHandle = fopen($fileName, "r");
3838
Index: trunk/extensions/Wikidata/WP/DataImport.php
@@ -2,115 +2,71 @@
33
44 define('MEDIAWIKI', true );
55 require_once("../../../LocalSettings.php");
6 -require_once("../WiktionaryZ/Expression.php");
76 require_once("Setup.php");
 7+require_once("../WiktionaryZ/Expression.php");
 8+require_once("../WiktionaryZ/Transaction.php");
89 require_once('SwissProtImport.php');
910 require_once('XMLImport.php');
1011 require_once('2GoMappingImport.php');
11 -require_once("ProgressBar.php");
1212 require_once("UMLSImport.php");
1313
14 -// Uncomment following line for versioning support
15 -require_once("../WiktionaryZ/Transaction.php");
16 -
1714 ob_end_flush();
1815
1916 global
20 - $beginTime, $wgCommandLineMode, $numberOfBytes;
 17+ $beginTime, $wgCommandLineMode, $wgUser, $numberOfBytes;
2118
2219 $beginTime = time();
2320 $wgCommandLineMode = true;
2421
 22+/*
 23+ * User IDs to use during the import of both UMLS and Swiss-Prot
 24+ */
 25+$nlmUserID = 8;
 26+$sibUserID = 10;
 27+
2528 $linkEC2GoFileName = "LinksEC2Go.txt";
2629 $linkSwissProtKeyWord2GoFileName = "LinksSP2Go.txt";
2730 $swissProtXMLFileName = "uniprot_sprot.xml";
2831 //$swissProtXMLFileName = "100000lines.xml";
2932
30 -$umlsImport = importUMLSFromDatabase("localhost", "umls", "root", "");
31 -$EC2GoMapping = importEC2GoMapping($linkEC2GoFileName);
32 -$SP2GoMapping = importSwissProtKeyWord2GoMapping($linkSwissProtKeyWord2GoFileName);
 33+$wgUser->setID($nlmUserID);
 34+startNewTransaction($nlmUserID, 0, "UMLS Import");
 35+echo "Importing UMLS\n";
 36+$umlsImport = importUMLSFromDatabase("localhost", "umls", "root", "nicheGod");//, array("NCI", "GO"));
3337
 38+$EC2GoMapping = loadEC2GoMapping($linkEC2GoFileName);
 39+$SP2GoMapping = loadSwissProtKeyWord2GoMapping($linkSwissProtKeyWord2GoFileName);
 40+
 41+$wgUser->setID($sibUserID);
 42+startNewTransaction($sibUserID, 0, "Swiss-Prot Import");
 43+echo "\nImporting Swiss-Prot\n";
 44+//importSwissProt($swissProtXMLFileName);
3445 importSwissProt($swissProtXMLFileName, $umlsImport->umlsCollectionId, $umlsImport->sourceAbbreviations['GO'], $EC2GoMapping, $SP2GoMapping);
3546 //importSwissProt($swissProtXMLFileName, 18, 25, $EC2GoMapping, $SP2GoMapping);
3647
3748 $endTime = time();
38 -echo "\nTime elapsed: " . durationToString($endTime - $beginTime);
 49+echo "\n\nTime elapsed: " . durationToString($endTime - $beginTime);
3950
40 -function echoNofLines($fileHandle, $numberOfLines) {
41 - $i = 0;
42 - do {
43 - $buffer = fgets($fileHandle);
44 - $buffer = rtrim($buffer,"\n");
45 - echo $buffer;
46 - $i += 1;
47 - } while($i < $numberOfLines || strpos($buffer, '</entry>') === false);
48 - echo "</uniprot>";
49 -}
 51+//function echoNofLines($fileHandle, $numberOfLines) {
 52+// $i = 0;
 53+// do {
 54+// $buffer = fgets($fileHandle);
 55+// $buffer = rtrim($buffer,"\n");
 56+// echo $buffer;
 57+// $i += 1;
 58+// } while($i < $numberOfLines || strpos($buffer, '</entry>') === false);
 59+// echo "</uniprot>";
 60+//}
 61+//
 62+//function echoLinesUntilText($fileHandle, $text) {
 63+// $found = false;
 64+// do {
 65+// $buffer = fgets($fileHandle);
 66+// $buffer = rtrim($buffer,"\n");
 67+// echo $buffer;
 68+// $found = strpos($buffer, $text) !== false;
 69+// } while(!$found || strpos($buffer, '</entry>') === false);
 70+// echo "</uniprot>";
 71+//}
5072
51 -function echoLinesUntilText($fileHandle, $text) {
52 - $found = false;
53 - do {
54 - $buffer = fgets($fileHandle);
55 - $buffer = rtrim($buffer,"\n");
56 - echo $buffer;
57 - $found = strpos($buffer, $text) !== false;
58 - } while(!$found || strpos($buffer, '</entry>') === false);
59 - echo "</uniprot>";
60 -}
61 -
62 -function importSwissProtEntries($fileHandle) {
63 -// $selectLanguageId = 'SELECT language_id FROM language_names WHERE language_name ="English"';
64 -// $dbr =& wfGetDB(DB_MASTER);
65 -// $queryResult = $dbr->query($selectLanguageId);
66 -//
67 -// if ($languageIdObject = $dbr->fetchObject($queryResult)){
68 -// $languageId = $languageIdObject->language_id;
69 -// }
70 -
71 - $languageId = 85;
72 - $collectionId = bootstrapCollection("Swiss-Prot", $languageId);
73 -
74 -// while (!feof($fileHandle)) {
75 - for ($i = 1; $i <= 1000; $i++) {
76 - $entry = new SwissProtImportEntry;
77 - $entry->import($fileHandle);
78 - $entry->echoEntry();
79 - $identifier = $entry->getIdentifier();
80 -
81 - $descriptionAttribute = $entry->getDescriptionAttribute();
82 - print_r($descriptionAttribute);
83 - $expression = findExpression($descriptionAttribute->protein->name, $languageId);
84 - if (!$expression) {
85 - $expression = createExpression($descriptionAttribute->protein->name, $languageId);
86 - $definedMeaningId = createNewDefinedMeaning($expression->id, $languageId, $descriptionAttribute->protein->name);
87 -
88 - addDefinedMeaningToCollection($definedMeaningId, $collectionId, $descriptionAttribute->protein->name);
89 - }
90 - }
91 -}
92 -
93 -function getPrefixAnalysis($fileHandle){
94 - $prefixArray=array();
95 -
96 - while (!feof($fileHandle)) {
97 - $buffer = fgets($fileHandle);
98 - $buffer = rtrim($buffer,"\n");
99 - $currentPrefix = substr($buffer, 0, 2);
100 -
101 - if ($currentPrefix != ""){
102 - if (!array_key_exists($currentPrefix, $prefixArray)) {
103 - $prefixArray[$currentPrefix]=1;
104 - }
105 - else {
106 - $prefixArray[$currentPrefix]+=1;
107 - }
108 - }
109 - }
110 -
111 - echo "Number of prefixes: " . count($prefixArray) . "\n";
112 - foreach ($prefixArray as $prefix => $value) {
113 - echo $prefix . ": $value\n";
114 - }
115 -}
116 -
11773 ?>
Index: trunk/extensions/Wikidata/WP/SwissProtImport.php
@@ -1,53 +1,45 @@
22 <?php
33
44 require_once('XMLImport.php');
 5+//require_once('ProgressBar.php');
 6+//require_once('..\WiktionaryZ\Expression.php');
57
6 -function importSwissProt($xmlFileName, $umlsCollectionId, $goCollectionId, $EC2GoMapping, $keyword2GoMapping) {
7 - // Uncomment following line for versioning support
8 - startNewTransaction(10, 0, "Swiss-Prot Import");
9 -
10 - // Find some UMLS concepts for cross references from SwissProt:
11 - $umlsTerms = array();
12 - $umlsTerms["protein"] = getCollectionMemberId($umlsCollectionId, "C0033684");
13 - $umlsTerms["gene"] = getCollectionMemberId($umlsCollectionId, "C0017337");
14 - $umlsTerms["organism"] = getCollectionMemberId($umlsCollectionId, "C0029235");
15 - $umlsTerms["protein fragment"] = getCollectionMemberId($umlsCollectionId, "C1335533");
16 -
 8+/*
 9+ * Import Swiss-Prot from the XML file. Be sure to have started a transaction first!
 10+ */
 11+function importSwissProt($xmlFileName, $umlsCollectionId = 0, $goCollectionId = 0, $EC2GoMapping = array(), $keyword2GoMapping = array()) {
1712 // Create mappings from EC numbers and SwissProt keywords to GO term meaning id's:
18 - $goCollection = getCollectionContents($goCollectionId);
19 -
2013 $EC2GoMeaningId = array();
21 - foreach ($EC2GoMapping as $EC => $GO) {
22 - if (array_key_exists($GO, $goCollection)) {
23 - $goMeaningId = $goCollection[$GO];
24 - $EC2GoMeaningId[$EC] = $goMeaningId;
25 - }
26 - }
 14+ $keyword2GoMeaningId = array();
2715
28 - $keyword2GoMeaningId = array();
29 - foreach ($keyword2GoMapping as $keyword => $GO) {
30 - if (array_key_exists($GO, $goCollection)) {
31 - $goMeaningId = $goCollection[$GO];
32 - $keyword2GoMeaningId[$keyword] = $goMeaningId;
 16+ if ($goCollectionId != 0) {
 17+ $goCollection = getCollectionContents($goCollectionId);
 18+
 19+ foreach ($EC2GoMapping as $EC => $GO) {
 20+ if (array_key_exists($GO, $goCollection)) {
 21+ $goMeaningId = $goCollection[$GO];
 22+ $EC2GoMeaningId[$EC] = $goMeaningId;
 23+ }
3324 }
 25+
 26+ foreach ($keyword2GoMapping as $keyword => $GO) {
 27+ if (array_key_exists($GO, $goCollection)) {
 28+ $goMeaningId = $goCollection[$GO];
 29+ $keyword2GoMeaningId[$keyword] = $goMeaningId;
 30+ }
 31+ }
3432 }
3533
3634 // SwissProt import:
3735 $numberOfBytes = filesize($xmlFileName);
38 - progressBar(0, $numberOfBytes);
 36+ initializeProgressBar($numberOfBytes, 5000000);
3937 $fileHandle = fopen($xmlFileName, "r");
40 - importEntriesFromXMLFile($fileHandle, $umlsTerms, $EC2GoMeaningId, $keyword2GoMeaningId);
 38+ importEntriesFromXMLFile($fileHandle, $umlsCollectionId, $EC2GoMeaningId, $keyword2GoMeaningId);
4139
4240 fclose($fileHandle);
4341 }
4442
45 -function importEntriesFromXMLFile($fileHandle, $umlsTerms, $EC2GoMeaningId, $keyword2GoMeaningId) {
46 -// $selectLanguageId = 'SELECT language_id FROM language_names WHERE language_name ="English"';
47 -// $queryResult = $dbr->query($selectLanguageId);
48 -// if ($languageIdObject = $dbr->fetchObject($queryResult)){
49 -// $languageId = $languageIdObject->language_id;
50 -// }
51 -
 43+function importEntriesFromXMLFile($fileHandle, $umlsCollectionId, $EC2GoMeaningIdMapping, $keyword2GoMeaningIdMapping) {
5244 $languageId = 85;
5345 $collectionId = bootstrapCollection("Swiss-Prot", $languageId, "");
5446 $classCollectionId = bootstrapCollection("Swiss-Prot classes", $languageId, "ATTR");
@@ -62,23 +54,19 @@
6355 $xmlParser->relationTypeCollectionId = $relationTypeCollectionId;
6456 $xmlParser->textAttibuteCollectionId = $textAttibuteCollectionId;
6557 $xmlParser->ECCollectionId = $ECCollectionId;
66 - $xmlParser->EC2GoMeaningIdMapping = $EC2GoMeaningId;
67 - $xmlParser->keyword2GoMeaningIdMapping = $keyword2GoMeaningId;
 58+ $xmlParser->EC2GoMeaningIdMapping = $EC2GoMeaningIdMapping;
 59+ $xmlParser->keyword2GoMeaningIdMapping = $keyword2GoMeaningIdMapping;
6860
69 - $xmlParser->setUMLSTerms($umlsTerms);
70 -// $xmlParser->classes["protein"] = $umlsTerms["protein"];
71 -// $xmlParser->addClass("protein");
72 -// $xmlParser->classes["protein fragment"] = $umlsTerms["protein fragment"];
73 -// $xmlParser->addClass("protein fragment");
74 -// $xmlParser->classes["organism"] = $umlsTerms["organism"];
75 -// $xmlParser->addClass("organism");
76 - $xmlParser->addClass("organism specific protein");
77 -// $xmlParser->classes["gene"] = $umlsTerms["gene"];
78 -// $xmlParser->addClass("gene");
79 - $xmlParser->addClass("organism specific gene");
80 - $xmlParser->addClass("text attribute");
81 - $xmlParser->addClass("enzyme commission number");
 61+ // Find some UMLS concepts for cross references from SwissProt:
 62+ if ($umlsCollectionId != 0) {
 63+ $xmlParser->proteinConceptId = getCollectionMemberId($umlsCollectionId, "C0033684");
 64+ $xmlParser->geneConceptId = getCollectionMemberId($umlsCollectionId, "C0017337");
 65+ $xmlParser->organismConceptId = getCollectionMemberId($umlsCollectionId, "C0029235");
 66+ $xmlParser->proteinFragmentConceptId = getCollectionMemberId($umlsCollectionId, "C1335533");
 67+ }
8268
 69+ $xmlParser->initialize();
 70+
8371 parseXML($fileHandle, $xmlParser);
8472 }
8573
@@ -93,34 +81,107 @@
9482 public $keyword2GoMeaningIdMapping;
9583 public $numberOfEntries = 0;
9684
97 - public $classes = array();
98 - public $relationTypes = array();
9985 public $proteins = array();
10086 public $species = array();
10187 public $genes = array();
10288 public $attributes = array();
10389 public $ECNumbers = array();
10490
105 - public function addClass($name) {
106 - if (array_key_exists($name, $this->classes)) {
107 - $definedMeaningId = $this->classes[$name];
108 - }
109 - else {
110 - $definedMeaningId = $this->addExpressionAsDefinedMeaning($name, $name, $name, $this->classCollectionId);
111 - $this->classes[$name] = $definedMeaningId;
112 - }
113 - return $definedMeaningId;
 91+ public $proteinConceptId = 0;
 92+ public $proteinFragmentConceptId = 0;
 93+ public $organismSpecificProteinConceptId = 0;
 94+ public $organismSpecificGeneId = 0;
 95+ public $geneConceptId = 0;
 96+ public $organismConceptId = 0;
 97+ public $referencedByConceptId = 0;
 98+ public $keywordConceptId = 0;
 99+ public $includesConceptId = 0;
 100+ public $includedInConceptId = 0;
 101+ public $containsConceptId = 0;
 102+ public $containedInConceptId = 0;
 103+ public $textAttributeConceptId = 0;
 104+ public $enzymeCommissionNumberConceptId = 0;
 105+ public $activityConceptId = 0;
 106+
 107+ protected function bootstrapDefinedMeaning($spelling, $definition) {
 108+ $expression = $this->getOrCreateExpression($spelling);
 109+ $definedMeaningId = createNewDefinedMeaning($expression->id, $this->languageId, $definition);
 110+
 111+ return $definedMeaningId;
114112 }
115113
116 - public function setUMLSTerms($umlsTerms) {
117 - foreach ($umlsTerms as $term => $definedMeaningId) {
118 - $this->classes[$term] = $definedMeaningId;
119 - addDefinedMeaningToCollectionIfNotPresent($definedMeaningId, $this->classCollectionId, $term);
120 - $this->relationTypes[$term] = $definedMeaningId;
121 - addDefinedMeaningToCollectionIfNotPresent($definedMeaningId, $this->relationTypeCollectionId, $term);
122 - }
 114+ protected function bootstrapConceptIds() {
 115+ if ($this->proteinConceptId == 0)
 116+ $this->proteinConceptId = $this->bootstrapDefinedMeaning("protein", "protein");
 117+
 118+ if ($this->proteinFragmentConceptId == 0)
 119+ $this->proteinFragmentConceptId = $this->bootstrapDefinedMeaning("protein fragment", "protein fragment");
 120+
 121+ if ($this->organismSpecificProteinConceptId == 0)
 122+ $this->organismSpecificProteinConceptId = $this->bootstrapDefinedMeaning("organism specific protein", "organism specific protein");
 123+
 124+ if ($this->organismSpecificGeneConceptId == 0)
 125+ $this->organismSpecificGeneConceptId = $this->bootstrapDefinedMeaning("organism specific gene", "organism specific gene");
 126+
 127+ if ($this->geneConceptId == 0)
 128+ $this->geneConceptId = $this->bootstrapDefinedMeaning("gene", "gene");
 129+
 130+ if ($this->organismConceptId == 0)
 131+ $this->organismConceptId = $this->bootstrapDefinedMeaning("organism", "organism");
 132+
 133+ if ($this->referencedByConceptId == 0)
 134+ $this->referencedByConceptId = $this->bootstrapDefinedMeaning("referenced by", "referenced by");
 135+
 136+ if ($this->keywordConceptId == 0)
 137+ $this->keywordConceptId = $this->bootstrapDefinedMeaning("keyword", "keyword");
 138+
 139+ if ($this->includesConceptId == 0)
 140+ $this->includesConceptId = $this->bootstrapDefinedMeaning("includes", "includes");
 141+
 142+ if ($this->includedInConceptId == 0)
 143+ $this->includedInConceptId = $this->bootstrapDefinedMeaning("included in", "included in");
 144+
 145+ if ($this->containsConceptId == 0)
 146+ $this->containsConceptId = $this->bootstrapDefinedMeaning("contains", "contains");
 147+
 148+ if ($this->containedInConceptId == 0)
 149+ $this->containedInConceptId = $this->bootstrapDefinedMeaning("contained in", "contained in");
 150+
 151+ if ($this->enzymeCommissionNumberConceptId == 0)
 152+ $this->enzymeCommissionNumberConceptId = $this->bootstrapDefinedMeaning("enzyme commission number", "organism specific gene");
 153+
 154+ if ($this->textAttributeConceptId == 0)
 155+ $this->textAttributeConceptId = $this->bootstrapDefinedMeaning("text attribute", "text attribute");
 156+
 157+ if ($this->activityConceptId == 0)
 158+ $this->activityConceptId = $this->bootstrapDefinedMeaning("activity", "activity");
123159 }
124160
 161+ public function initialize() {
 162+ $this->bootstrapConceptIds();
 163+
 164+ // Add concepts to classes
 165+ addDefinedMeaningToCollectionIfNotPresent($this->proteinConceptId, $this->classCollectionId, "protein");
 166+ addDefinedMeaningToCollectionIfNotPresent($this->proteinFragmentConceptId, $this->classCollectionId, "protein fragment");
 167+ addDefinedMeaningToCollectionIfNotPresent($this->geneConceptId, $this->classCollectionId, "gene");
 168+ addDefinedMeaningToCollectionIfNotPresent($this->organismConceptId, $this->classCollectionId, "organism");
 169+ addDefinedMeaningToCollectionIfNotPresent($this->organismSpecificProteinConceptId, $this->classCollectionId, "organism specific protein");
 170+ addDefinedMeaningToCollectionIfNotPresent($this->textAttributeConceptId, $this->classCollectionId, "text attribute");
 171+ addDefinedMeaningToCollectionIfNotPresent($this->enzymeCommissionNumberConceptId, $this->classCollectionId, "enzyme commission number");
 172+
 173+ // Add concepts to relation types
 174+ addDefinedMeaningToCollectionIfNotPresent($this->proteinConceptId, $this->relationTypeCollectionId, "protein");
 175+ addDefinedMeaningToCollectionIfNotPresent($this->referencedByConceptId, $this->relationTypeCollectionId, "referenced by");
 176+ addDefinedMeaningToCollectionIfNotPresent($this->geneConceptId, $this->relationTypeCollectionId, "gene");
 177+ addDefinedMeaningToCollectionIfNotPresent($this->organismConceptId, $this->relationTypeCollectionId, "organism");
 178+ addDefinedMeaningToCollectionIfNotPresent($this->activityConceptId, $this->relationTypeCollectionId, "activity");
 179+ addDefinedMeaningToCollectionIfNotPresent($this->keywordConceptId, $this->relationTypeCollectionId, "keyword");
 180+ addDefinedMeaningToCollectionIfNotPresent($this->includesConceptId, $this->relationTypeCollectionId, "includes");
 181+ addDefinedMeaningToCollectionIfNotPresent($this->includedInConceptId, $this->relationTypeCollectionId, "included in");
 182+ addDefinedMeaningToCollectionIfNotPresent($this->containsConceptId, $this->relationTypeCollectionId, "contains");
 183+ addDefinedMeaningToCollectionIfNotPresent($this->containedInConceptId, $this->relationTypeCollectionId, "contained in");
 184+ }
 185+
125186 public function startElement($parser, $name, $attributes) {
126187 global
127188 $numberOfBytes;
@@ -133,10 +194,11 @@
134195 $this->stack[] = $handler;
135196 }
136197 else {
137 - if (count($this->stack) == 1 && $this->numberOfEntries % 10 == 0) {
 198+ if (count($this->stack) == 1) {
138199 $currentByteIndex = xml_get_current_byte_index($parser);
139 - progressBar($currentByteIndex, $numberOfBytes);
 200+ setProgressBarPosition($currentByteIndex);
140201 }
 202+
141203 BaseXMLParser::startElement($parser, $name, $attributes);
142204 }
143205 }
@@ -167,9 +229,9 @@
168230 }
169231
170232 if($protein->fragment)
171 - addRelation($definedMeaningId, 0, $this->classes["protein fragment"]);
 233+ addClassMembership($definedMeaningId, $this->proteinFragmentConceptId);
172234 else
173 - addRelation($definedMeaningId, 0, $this->classes["protein"]);
 235+ addClassMembership($definedMeaningId, $this->proteinConceptId);
174236
175237 return $definedMeaningId;
176238 }
@@ -183,7 +245,7 @@
184246 $this->genes[$name] = $definedMeaningId;
185247 }
186248
187 - addRelation($definedMeaningId, 0, $this->classes["gene"]);
 249+ addClassMembership($definedMeaningId, $this->geneConceptId);
188250
189251 foreach ($synonyms as $key => $synonym) {
190252 addSynonymOrTranslation($synonym, $this->languageId, $definedMeaningId, true);
@@ -201,7 +263,7 @@
202264 $this->species[$name] = $definedMeaningId;
203265 }
204266
205 - addRelation($definedMeaningId, 0, $this->classes["organism"]);
 267+ addClassMembership($definedMeaningId, $this->organismConceptId);
206268
207269 foreach ($translations as $key => $translation) {
208270 addSynonymOrTranslation($translation, $this->languageId, $definedMeaningId, true);
@@ -211,51 +273,39 @@
212274 }
213275
214276 public function addEntry($entry, $proteinMeaningId, $geneMeaningId, $organismSpeciesMeaningId) {
215 - $activityLabel = "activity";
216 - $proteinLabel = "protein";
217 - $referencedByLabel = "referenced by";
218 - $geneLabel = "gene";
219 - $organismLabel = "organism";
220 - $includesLabel = "includes";
221 - $includedInLabel = "included in";
222 - $containsLabel = "contains";
223 - $containedInLabel = "contained in";
224 - $keywordLabel = "keyword";
225 -
226 -
227 -// change name to make sure it works in wiki-urls:
 277+ // change name to make sure it works in wiki-urls:
228278 $swissProtExpression = str_replace('_', '-', $entry->name);
229279 $entryExpression = $entry->protein->name . ' in ' . $entry->organism;
230280
231 -// add the expression as defined meaning:
 281+ // add the expression as defined meaning:
232282 $expression = $this->getOrCreateExpression($entryExpression);
233283 $definedMeaningId = createNewDefinedMeaning($expression->id, $this->languageId, $entryExpression);
234284 addDefinedMeaningToCollection($definedMeaningId, $this->collectionId, $entry->accession);
235285
236 -// Add entry synonyms: Swiss-Prot entry name and species specific protein synonyms
 286+ // Add entry synonyms: Swiss-Prot entry name and species specific protein synonyms
237287 addSynonymOrTranslation($swissProtExpression, $this->languageId, $definedMeaningId, true);
238288
239289 foreach ($entry->protein->synonyms as $key => $synonym)
240290 addSynonymOrTranslation($synonym, $this->languageId, $definedMeaningId, true);
241291
242 -// set the class of the entry:
243 - addRelation($definedMeaningId, 0, $this->classes["organism specific protein"]);
 292+ // set the class of the entry:
 293+ addClassMembership($definedMeaningId, $this->organismSpecificProteinConceptId);
244294
245 -// set the protein of the swiss prot entry and relate the protein to the entry:
246 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($proteinLabel), $proteinMeaningId);
247 - addRelation($proteinMeaningId, $this->getOrCreateRelationTypeMeaningId($referencedByLabel), $definedMeaningId);
 295+ // set the protein of the swiss prot entry and relate the protein to the entry:
 296+ addRelation($definedMeaningId, $this->proteinConceptId, $proteinMeaningId);
 297+ addRelation($proteinMeaningId, $this->referencedByConceptId, $definedMeaningId);
248298
249 -// set the gene of the swiss prot entry and relate the gene to the entry:
 299+ // set the gene of the swiss prot entry and relate the gene to the entry:
250300 if($geneMeaningId >= 0) {
251 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($geneLabel), $geneMeaningId);
252 - addRelation($geneMeaningId, $this->getOrCreateRelationTypeMeaningId($referencedByLabel), $definedMeaningId);
 301+ addRelation($definedMeaningId, $this->geneConceptId, $geneMeaningId);
 302+ addRelation($geneMeaningId, $this->referencedByConceptId, $definedMeaningId);
253303 }
254304
255 -// set the species of the swiss prot entry and relate the species to the entry:
256 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($organismLabel), $organismSpeciesMeaningId);
257 - addRelation($organismSpeciesMeaningId, $this->getOrCreateRelationTypeMeaningId($referencedByLabel), $definedMeaningId);
 305+ // set the species of the swiss prot entry and relate the species to the entry:
 306+ addRelation($definedMeaningId, $this->organismConceptId, $organismSpeciesMeaningId);
 307+ addRelation($organismSpeciesMeaningId, $this->referencedByConceptId, $definedMeaningId);
258308
259 -// add the comment fields as text attributes:
 309+ // add the comment fields as text attributes:
260310 foreach ($entry->comments as $key => $comment) {
261311 $attributeMeaningId = $this->getOrCreateAttributeMeaningId($comment->type);
262312 $textValue = $comment->text;
@@ -266,34 +316,34 @@
267317 addDefinedMeaningTextAttributeValue($definedMeaningId, $attributeMeaningId, $this->languageId, $textValue);
268318 }
269319
270 -// add EC number:
 320+ // add EC number:
271321 if($entry->EC != ""){
272322 $ECNumberMeaningId = $this->getOrCreateECNumberMeaningId($entry->EC);
273 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($activityLabel), $ECNumberMeaningId);
274 - addRelation($ECNumberMeaningId, $this->getOrCreateRelationTypeMeaningId($referencedByLabel), $definedMeaningId);
 323+ addRelation($definedMeaningId, $this->activityConceptId, $ECNumberMeaningId);
 324+ addRelation($ECNumberMeaningId, $this->referencedByConceptId, $definedMeaningId);
275325 }
276326
277 -// add keywords:
 327+ // add keywords:
278328 foreach ($entry->keywords as $key => $keyword) {
279329 if (array_key_exists($keyword, $this->keyword2GoMeaningIdMapping)) {
280330 $goMeaningId = $this->keyword2GoMeaningIdMapping[$keyword];
281 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($keywordLabel), $goMeaningId);
282 - addRelation($goMeaningId, $this->getOrCreateRelationTypeMeaningId($referencedByLabel), $definedMeaningId);
 331+ addRelation($definedMeaningId, $this->keywordConceptId, $goMeaningId);
 332+ addRelation($goMeaningId, $this->referencedByConceptId, $definedMeaningId);
283333 }
284334 }
285335
286 -// Add protein includes relations
 336+ // Add protein includes relations
287337 foreach ($entry->protein->domains as $key => $domain) {
288338 $domainMeaningId = $this->addProtein($domain);
289 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($includesLabel), $domainMeaningId);
290 - addRelation($domainMeaningId, $this->getOrCreateRelationTypeMeaningId($includedInLabel), $definedMeaningId);
 339+ addRelation($definedMeaningId, $this->includesConceptId, $domainMeaningId);
 340+ addRelation($domainMeaningId, $this->includedInConceptId, $definedMeaningId);
291341 }
292342
293 -// Add protein includes relations
 343+ // Add protein includes relations
294344 foreach ($entry->protein->components as $key => $component) {
295345 $componentMeaningId = $this->addProtein($component);
296 - addRelation($definedMeaningId, $this->getOrCreateRelationTypeMeaningId($containsLabel), $componentMeaningId);
297 - addRelation($componentMeaningId, $this->getOrCreateRelationTypeMeaningId($containedInLabel), $definedMeaningId);
 346+ addRelation($definedMeaningId, $this->containsConceptId, $componentMeaningId);
 347+ addRelation($componentMeaningId, $this->containedInConceptId, $definedMeaningId);
298348 }
299349
300350 return $definedMeaningId;
@@ -305,7 +355,7 @@
306356 }
307357 else {
308358 $definedMeaningId = $this->addExpressionAsDefinedMeaning($attribute, $attribute, $attribute, $this->textAttibuteCollectionId);
309 - addRelation($definedMeaningId, 0, $this->classes["text attribute"]);
 359+ addClassMembership($definedMeaningId, $this->textAttributeConceptId);
310360 $this->attributes[$attribute] = $definedMeaningId;
311361 }
312362 return $definedMeaningId;
@@ -315,7 +365,7 @@
316366 if (array_key_exists($EC, $this->ECNumbers)) {
317367 $definedMeaningId = $this->ECNumbers[$EC];
318368 }
319 - elseif(array_key_exists($EC, $this->EC2GoMeaningIdMapping)) {
 369+ elseif (array_key_exists($EC, $this->EC2GoMeaningIdMapping)) {
320370 $definedMeaningId = $this->EC2GoMeaningIdMapping[$EC];
321371 $this->ECNumbers[$EC] = $definedMeaningId;
322372 $expression = $this->getOrCreateExpression($EC);
@@ -323,7 +373,7 @@
324374 }
325375 else {
326376 $definedMeaningId = $this->addExpressionAsDefinedMeaning($EC, $EC, $EC, $this->ECCollectionId);
327 - addRelation($definedMeaningId, 0, $this->classes["enzyme commission number"]);
 377+ addClassMembership($definedMeaningId, $this->enzymeCommissionNumberConceptId);
328378 $this->ECNumbers[$EC] = $definedMeaningId;
329379 }
330380 return $definedMeaningId;
@@ -343,17 +393,6 @@
344394 addDefinedMeaningToCollection($definedMeaningId, $collectionId, $internalIdentifier);
345395 return $definedMeaningId;
346396 }
347 -
348 - public function getOrCreateRelationTypeMeaningId($spelling) {
349 - if (array_key_exists($spelling, $this->relationTypes)){
350 - $relationTypeMeaningId = $this->relationTypes[$spelling];
351 - }
352 - else {
353 - $relationTypeMeaningId = $this->addExpressionAsDefinedMeaning($spelling, $spelling, $spelling, $this->relationTypeCollectionId);
354 - $this->relationTypes[$spelling] = $relationTypeMeaningId;
355 - }
356 - return $relationTypeMeaningId;
357 - }
358397 }
359398
360399 class UniProtXMLElementHandler extends DefaultXMLElementHandler {