Changeset 16256
- Timestamp:
- 18/07/08 11:51:41 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bio/sources/psi/main/src/org/intermine/bio/dataconversion/PsiConverter.java
r16048 r16256 59 59 private Map<String, String> terms = new HashMap<String, String>(); 60 60 private Map<String, String> masterList = new HashMap<String, String>(); 61 private static String datasetId;62 //private int nextClsId;63 64 61 65 62 /** … … 189 186 throws SAXException { 190 187 attName = null; 191 192 188 // <experimentList><experimentDescription> 193 189 if (qName.equals("experimentDescription")) { 194 // this experiment may have already been created195 // we won't know until the name is processed196 190 try { 197 191 experimentId = attrs.getValue("id"); … … 199 193 throw new SAXException(e); 200 194 } 201 202 // <experimentList><experimentDescription id="2"><names><shortLabel> 203 } else if (qName.equals("shortLabel") 204 && stack.peek().equals("names") 195 // <experimentList><experimentDescription id="2"><names><shortLabel> 196 } else if (qName.equals("shortLabel") && stack.peek().equals("names") 205 197 && stack.search("experimentDescription") == 2) { 206 /* experiment.experimentName = shortName */207 198 attName = "experimentName"; 208 209 //<experimentList><experimentDescription><bibref><xref><primaryRef> 210 } else if (qName.equals("primaryRef") 211 && stack.peek().equals("xref") 199 //<experimentList><experimentDescription><bibref><xref><primaryRef> 200 } else if (qName.equals("primaryRef") && stack.peek().equals("xref") 212 201 && stack.search("bibref") == 2 213 202 && stack.search("experimentDescription") == 3) { … … 217 206 experimentHolder.setPublication(pub); 218 207 } 219 220 //<experimentList><experimentDescription><attributeList><attribute> 221 } else if (qName.equals("attribute") 222 && stack.peek().equals("attributeList") 208 //<experimentList><experimentDescription><attributeList><attribute> 209 } else if (qName.equals("attribute") && stack.peek().equals("attributeList") 223 210 && stack.search("experimentDescription") == 2) { 224 211 String name = attrs.getValue("name"); … … 227 214 setComment(); 228 215 comment.setAttribute("type", name); 229 // String title = experimentHolder.name;230 // Item item = getInfoSource(title);231 // comment.setReference("source", item.getIdentifier());232 216 attName = "experimentAttribute"; 233 217 } else { 234 218 LOG.info("Can't create comment, bad experiment."); 235 219 } 236 237 // <hostOrganismList><hostOrganism ncbiTaxId="9534"><names><fullName> 238 } else if (qName.equals("fullName") 239 && stack.peek().equals("names") 220 // <hostOrganismList><hostOrganism ncbiTaxId="9534"><names><fullName> 221 } else if (qName.equals("fullName") && stack.peek().equals("names") 240 222 && stack.search("hostOrganism") == 3) { 241 223 attName = "hostOrganismName"; 242 243 //<interactionDetectionMethod><xref><primaryRef> 244 } else if (qName.equals("primaryRef") 245 && stack.peek().equals("xref") 224 //<interactionDetectionMethod><xref><primaryRef> 225 } else if (qName.equals("primaryRef") && stack.peek().equals("xref") 246 226 && stack.search("interactionDetectionMethod") == 2) { 247 String id = attrs.getValue("id"); 248 String termItemId = getTerm(id); 227 String termItemId = getTerm(attrs.getValue("id")); 249 228 experimentHolder.setMethod("interactionDetectionMethod", termItemId); 250 251 //<participantIdentificationMethod><xref> <primaryRef> 252 } else if (qName.equals("primaryRef") 253 && stack.peek().equals("xref") 229 //<participantIdentificationMethod><xref> <primaryRef> 230 } else if (qName.equals("primaryRef") && stack.peek().equals("xref") 254 231 && stack.search("participantIdentificationMethod") == 2) { 255 String id = attrs.getValue("id"); 256 String termItemId = getTerm(id); 232 String termItemId = getTerm(attrs.getValue("id")); 257 233 experimentHolder.setMethod("participantIdentificationMethod", termItemId); 258 259 // <interactorList><interactor id="4"> 260 } else if (qName.equals("interactor") 261 && stack.peek().equals("interactorList")) { 234 // <interactorList><interactor id="4"> 235 } else if (qName.equals("interactor") && stack.peek().equals("interactorList")) { 262 236 proteinId = attrs.getValue("id"); 263 264 // <interactorList><interactor id="4"><organism ncbiTaxId="7227"> 265 } else if (qName.equals("organism") 266 && stack.peek().equals("interactor")) { 267 /* if organism is valid, put the protein in our list for later reference */ 237 // <interactorList><interactor id="4"><organism ncbiTaxId="7227"> 238 } else if (qName.equals("organism") && stack.peek().equals("interactor")) { 268 239 String taxId = attrs.getValue("ncbiTaxId"); 269 if (organisms.containsKey(taxId)) { 270 if (protein != null) { 271 protein.setReference("organism", organisms.get(taxId)); 272 if (!validProteins.containsKey(proteinId)) { 273 validProteins.put(proteinId, protein.getIdentifier()); 274 } 275 } 276 } 277 278 // <interactorList><interactor id="4"><xref><primaryRef> 279 } else if (qName.equals("primaryRef") 280 && stack.peek().equals("xref") 240 if (organisms.containsKey(taxId) && protein != null) { 241 protein.setReference("organism", organisms.get(taxId)); 242 if (!validProteins.containsKey(proteinId)) { 243 validProteins.put(proteinId, protein.getIdentifier()); 244 } 245 } 246 // <interactorList><interactor id="4"><xref><primaryRef> 247 } else if (qName.equals("primaryRef") && stack.peek().equals("xref") 281 248 && stack.search("interactor") == 2) { 282 249 String db = attrs.getValue("db"); … … 310 277 protein.setCollection("dataSets", new ArrayList(Collections.singleton( 311 278 masterList.get("datasetId")))); 312 313 314 // TODO this should maybe create a data source for each db315 279 Item synonym = createItem("Synonym"); 316 280 synonym.setAttribute("value", id); … … 320 284 synonym.setReference("subject", proteinRefId); 321 285 synonyms.add(synonym); 322 323 286 // create an extra synonym for proteins that have an IntAct identifier 324 287 if (db.equals("intact")) { … … 330 293 synonyms.add(synonym); 331 294 } 332 333 295 // see ticket #1450 334 296 Item syn2 = createItem("Synonym"); … … 339 301 synonyms.add(synonym); 340 302 } 341 342 // <interactorList><interactor id="4"><sequence> 343 } else if (qName.equals("sequence") 344 && stack.peek().equals("interactor")) { 345 303 // <interactorList><interactor id="4"><sequence> 304 } else if (qName.equals("sequence") && stack.peek().equals("interactor")) { 346 305 attName = "sequence"; 347 348 //<interactionList><interaction id="1"><names><shortLabel> 349 } else if (qName.equals("shortLabel") 350 && stack.peek().equals("names") 306 //<interactionList><interaction id="1"><names><shortLabel> 307 } else if (qName.equals("shortLabel") && stack.peek().equals("names") 351 308 && stack.search("interaction") == 2) { 352 353 309 attName = "interactionName"; 354 355 //<interaction><confidenceList><confidence><unit><names><shortLabel> 356 } else if (qName.equals("shortLabel") 357 && stack.peek().equals("names") 310 //<interaction><confidenceList><confidence><unit><names><shortLabel> 311 } else if (qName.equals("shortLabel") && stack.peek().equals("names") 358 312 && stack.search("confidence") == 3) { 359 360 313 attName = "confidenceUnit"; 361 362 //<interactionList><interaction><confidenceList><confidence><value> 363 } else if (qName.equals("value") 364 && stack.peek().equals("confidence")) { 365 314 //<interactionList><interaction><confidenceList><confidence><value> 315 } else if (qName.equals("value") && stack.peek().equals("confidence")) { 366 316 attName = "confidence"; 367 368 //<interactionList><interaction> 369 //<participantList><participant id="5"><interactorRef> 317 //<interactionList><interaction> 318 //<participantList><participant id="5"><interactorRef> 370 319 } else if (qName.equals("interactorRef") 371 320 && stack.peek().equals("participant")) { 372 373 321 attName = "participantId"; 374 375 // <participantList><participant id="5"><experimentalRole><names><shortLabel> 376 } else if (qName.equals("shortLabel") 377 && stack.search("experimentalRole") == 2) { 378 322 // <participantList><participant id="5"><experimentalRole><names><shortLabel> 323 } else if (qName.equals("shortLabel") && stack.search("experimentalRole") == 2) { 379 324 attName = "proteinRole"; 380 381 //<interactionList><interaction><experimentList><experimentRef> 382 } else if (qName.equals("experimentRef") 383 && stack.peek().equals("experimentList")) { 325 //<interactionList><interaction><experimentList><experimentRef> 326 } else if (qName.equals("experimentRef") && stack.peek().equals("experimentList")) { 384 327 attName = "experimentRef"; 385 386 // <participantList><participant id="6919"><featureList><feature id="6920"> 387 // <featureRangeList><featureRange><startStatus><names><shortLabel> 388 } else if (qName.equals("shortLabel") 389 && stack.search("startStatus") == 2) { 390 328 // <participantList><participant id="6919"><featureList><feature id="6920"> 329 // <featureRangeList><featureRange><startStatus><names><shortLabel> 330 } else if (qName.equals("shortLabel") && stack.search("startStatus") == 2) { 391 331 attName = "startStatus"; 392 393 // <participantList><participant id="6919"><featureList><feature id="6920"> 394 // <featureRangeList><featureRange><endStatus><names><shortLabel> 395 } else if (qName.equals("shortLabel") 396 && stack.search("endStatus") == 2) { 397 332 // <participantList><participant id="6919"><featureList><feature id="6920"> 333 // <featureRangeList><featureRange><endStatus><names><shortLabel> 334 } else if (qName.equals("shortLabel") && stack.search("endStatus") == 2) { 398 335 attName = "endStatus"; 399 400 401 // <featureList><feature id="24"><names><shortLabel> 402 } else if (qName.equals("shortLabel") 403 && stack.search("feature") == 2) { 404 336 // <featureList><feature id="24"><names><shortLabel> 337 } else if (qName.equals("shortLabel") && stack.search("feature") == 2) { 405 338 attName = "regionName"; 406 407 339 // <participantList><participant id="6919"><featureList><feature id="6920"> 408 340 // <featureType><xref><primaryRef db="psi-mi" dbAc="MI:0488" id="MI:0117" 409 } else if (qName.equals("primaryRef") 410 && stack.search("featureType") == 2 411 && attrs.getValue("id").equals("MI:0117") 412 && interactorHolder != null) { 413 341 } else if (qName.equals("primaryRef") && stack.search("featureType") == 2 342 && attrs.getValue("id").equals("MI:0117") && interactorHolder != null) { 414 343 interactorHolder.isRegionFeature = true; 415 416 344 // create interacting region 417 345 Item interactionRegion = createItem("ProteinInteractionRegion"); … … 419 347 interactionRegion.setReference("protein", interactorHolder.proteinId); 420 348 interactionRegion.setReference("ontologyTerm", psiDagTermItemId); 421 422 349 423 350 // create new location object (start and end are coming later) … … 440 367 && interactorHolder != null 441 368 && interactorHolder.isRegionFeature) { 442 443 String start = attrs.getValue("position"); 444 interactorHolder.setStart(start); 445 446 // <participantList><participant id="6919"><featureList><feature id="6920"> 447 // <featureRangeList><featureRange><end position="470"/> 369 interactorHolder.setStart(attrs.getValue("position")); 370 // <participantList><participant id="6919"><featureList><feature id="6920"> 371 // <featureRangeList><featureRange><end position="470"/> 448 372 } else if (qName.equals("end") 449 373 && stack.peek().equals("featureRange") 450 374 && interactorHolder != null 451 375 && interactorHolder.isRegionFeature) { 452 453 String end = attrs.getValue("position"); 454 interactorHolder.setEnd(end); 455 456 // <entry> 457 } else if (qName.equals("entry")) { 376 interactorHolder.setEnd(attrs.getValue("position")); 377 378 } else if (qName.equals("entry")) { // <entry> 458 379 /* stuff done only once */ 459 380 if (masterList.size() <= 1) { … … 472 393 */ 473 394 public void characters(char[] ch, int start, int length) { 395 int st = start; 396 int l = length; 474 397 475 398 if (attName != null) { … … 477 400 // DefaultHandler may call this method more than once for a single 478 401 // attribute content -> hold text & create attribute in endElement 479 while (l ength> 0) {402 while (l > 0) { 480 403 boolean whitespace = false; 481 switch(ch[st art]) {404 switch(ch[st]) { 482 405 case ' ': 483 406 case '\r': … … 492 415 break; 493 416 } 494 ++st art;495 --l ength;496 } 497 498 if (l ength> 0) {417 ++st; 418 --l; 419 } 420 421 if (l > 0) { 499 422 StringBuffer s = new StringBuffer(); 500 s.append(ch, st art, length);423 s.append(ch, st, l); 501 424 attValue.append(s); 502 425 } … … 524 447 if (comment != null && s != null) { 525 448 //TODO store these only when valid experiment 526 if ( s != null &&!s.equals("")) {449 if (!s.equals("")) { 527 450 comment.setAttribute("text", s); 528 451 }
