Changeset 16256

Show
Ignore:
Timestamp:
18/07/08 11:51:41 (1 month ago)
Author:
julie
Message:

checkstyle

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bio/sources/psi/main/src/org/intermine/bio/dataconversion/PsiConverter.java

    r16048 r16256  
    5959    private Map<String, String> terms = new HashMap<String, String>(); 
    6060    private Map<String, String> masterList = new HashMap<String, String>(); 
    61     private static String datasetId; 
    62     //private int nextClsId; 
    63  
    6461 
    6562    /** 
     
    189186            throws SAXException { 
    190187            attName = null; 
    191  
    192188            // <experimentList><experimentDescription> 
    193189            if (qName.equals("experimentDescription")) { 
    194                 // this experiment may have already been created 
    195                 // we won't know until the name is processed 
    196190                try { 
    197191                    experimentId = attrs.getValue("id"); 
     
    199193                    throw new SAXException(e); 
    200194                } 
    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") 
    205197                       && stack.search("experimentDescription") == 2) { 
    206                 /* experiment.experimentName = shortName */ 
    207198                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") 
    212201                       && stack.search("bibref") == 2 
    213202                       && stack.search("experimentDescription") == 3) { 
     
    217206                    experimentHolder.setPublication(pub); 
    218207                } 
    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") 
    223210                       && stack.search("experimentDescription") == 2) { 
    224211                String name = attrs.getValue("name"); 
     
    227214                    setComment(); 
    228215                    comment.setAttribute("type", name); 
    229                     //                        String title = experimentHolder.name; 
    230                     //                        Item item = getInfoSource(title); 
    231                     //                        comment.setReference("source", item.getIdentifier()); 
    232216                    attName = "experimentAttribute"; 
    233217                } else { 
    234218                    LOG.info("Can't create comment, bad experiment."); 
    235219                } 
    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") 
    240222                       && stack.search("hostOrganism") == 3) { 
    241223                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") 
    246226                       && stack.search("interactionDetectionMethod") == 2) { 
    247                 String id = attrs.getValue("id"); 
    248                 String termItemId = getTerm(id); 
     227                String termItemId = getTerm(attrs.getValue("id")); 
    249228                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") 
    254231                       && stack.search("participantIdentificationMethod") == 2) { 
    255                 String id = attrs.getValue("id"); 
    256                 String termItemId = getTerm(id); 
     232                String termItemId = getTerm(attrs.getValue("id")); 
    257233                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")) { 
    262236                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")) { 
    268239                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") 
    281248                       && stack.search("interactor") == 2) { 
    282249                String db = attrs.getValue("db"); 
     
    310277                    protein.setCollection("dataSets", new ArrayList(Collections.singleton( 
    311278                                                                    masterList.get("datasetId")))); 
    312  
    313  
    314                     // TODO this should maybe create a data source for each db 
    315279                    Item synonym = createItem("Synonym"); 
    316280                    synonym.setAttribute("value", id); 
     
    320284                    synonym.setReference("subject", proteinRefId); 
    321285                    synonyms.add(synonym); 
    322  
    323286                    // create an extra synonym for proteins that have an IntAct identifier 
    324287                    if (db.equals("intact")) { 
     
    330293                        synonyms.add(synonym); 
    331294                    } 
    332  
    333295                    // see ticket #1450 
    334296                    Item syn2 = createItem("Synonym"); 
     
    339301                    synonyms.add(synonym); 
    340302                } 
    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")) { 
    346305                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") 
    351308                       && stack.search("interaction") == 2) { 
    352  
    353309                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") 
    358312                       && stack.search("confidence") == 3) { 
    359  
    360313                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")) { 
    366316                attName = "confidence"; 
    367  
    368                 //<interactionList><interaction> 
    369                 //<participantList><participant id="5"><interactorRef> 
     317            //<interactionList><interaction> 
     318            //<participantList><participant id="5"><interactorRef> 
    370319            } else if (qName.equals("interactorRef") 
    371320                       && stack.peek().equals("participant")) { 
    372  
    373321                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) { 
    379324                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")) { 
    384327                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) { 
    391331                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) { 
    398335                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) { 
    405338                attName = "regionName"; 
    406  
    407339            // <participantList><participant id="6919"><featureList><feature id="6920"> 
    408340            // <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) { 
    414343                interactorHolder.isRegionFeature = true; 
    415  
    416344                // create interacting region 
    417345                Item interactionRegion = createItem("ProteinInteractionRegion"); 
     
    419347                interactionRegion.setReference("protein", interactorHolder.proteinId); 
    420348                interactionRegion.setReference("ontologyTerm", psiDagTermItemId); 
    421  
    422349 
    423350                // create new location object (start and end are coming later) 
     
    440367                       && interactorHolder != null 
    441368                       && 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"/> 
    448372            } else if (qName.equals("end") 
    449373                       && stack.peek().equals("featureRange") 
    450374                       && interactorHolder != null 
    451375                       && 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> 
    458379                /* stuff done only once */ 
    459380                if (masterList.size() <= 1) { 
     
    472393         */ 
    473394        public void characters(char[] ch, int start, int length) { 
     395            int st = start; 
     396            int l = length; 
    474397 
    475398            if (attName != null) { 
     
    477400                // DefaultHandler may call this method more than once for a single 
    478401                // attribute content -> hold text & create attribute in endElement 
    479                 while (length > 0) { 
     402                while (l > 0) { 
    480403                    boolean whitespace = false; 
    481                     switch(ch[start]) { 
     404                    switch(ch[st]) { 
    482405                    case ' ': 
    483406                    case '\r': 
     
    492415                        break; 
    493416                    } 
    494                     ++start
    495                     --length
    496                 } 
    497  
    498                 if (length > 0) { 
     417                    ++st
     418                    --l
     419                } 
     420 
     421                if (l > 0) { 
    499422                    StringBuffer s = new StringBuffer(); 
    500                     s.append(ch, start, length); 
     423                    s.append(ch, st, l); 
    501424                    attValue.append(s); 
    502425                } 
     
    524447                    if (comment != null && s != null) { 
    525448                        //TODO store these only when valid experiment 
    526                         if (s != null && !s.equals("")) { 
     449                        if (!s.equals("")) { 
    527450                            comment.setAttribute("text", s); 
    528451                        }