Changeset 16240

Show
Ignore:
Timestamp:
16/07/08 14:27:49 (1 month ago)
Author:
julie
Message:

for protein structures, make synonyms for proteins

Files:

Legend:

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

    r16018 r16240  
    2222import java.util.Stack; 
    2323 
     24import org.apache.commons.lang.StringUtils; 
    2425import org.apache.log4j.Logger; 
    2526import org.intermine.InterMineException; 
     
    4647    private final Map<String, String> proteinMap = new HashMap<String, String>(); 
    4748    private String parentDir; 
     49    private Map<String, Item> synonyms = new HashMap<String, Item>(); 
    4850 
    4951    /** 
     
    240242        } 
    241243 
    242         private String getProtein(String identifier)
     244        private String getProtein(String identifier) throws ObjectStoreException
    243245            String proteinIdentifier = proteinMap.get(identifier); 
    244246            if (proteinIdentifier == null) { 
     
    246248                protein.setAttribute("primaryAccession", identifier); 
    247249                proteinMap.put(identifier, protein.getIdentifier()); 
    248                 try { 
    249                     store(protein); 
    250                 } catch (ObjectStoreException e) { 
    251                     throw new RuntimeException("error while storing: " + proteinItemIdentifier, e); 
    252                 } 
     250                store(protein); 
     251                createSynonym(protein.getIdentifier(), "accession", identifier); 
    253252                return protein.getIdentifier(); 
    254253            } 
     
    304303        } 
    305304    } 
     305 
     306    private Item createSynonym(String subjectId, String type, String value) 
     307    throws ObjectStoreException { 
     308        String key = subjectId + type + value; 
     309        if (StringUtils.isEmpty(value)) { 
     310            return null; 
     311        } 
     312        if (!synonyms.containsKey(key)) { 
     313            Item syn = createItem("Synonym"); 
     314            syn.setReference("subject", subjectId); 
     315            syn.setAttribute("type", type); 
     316            syn.setAttribute("value", value); 
     317            store(syn); 
     318            synonyms.put(key, syn); 
     319            return syn; 
     320        } 
     321        return null; 
     322    } 
    306323} 
  • trunk/bio/sources/protein_structure/test/resources/ProteinStructureConverterTest_tgt.xml

    r16018 r16240  
    99<attribute name="start" value="66"/> 
    1010<attribute name="technique" value="Computer prediction"/> 
    11 <reference name="proteinDomain" ref_id="4_1"/> 
     11<reference name="proteinDomain" ref_id="5_1"/> 
    1212<collection name="proteins"><reference ref_id="3_1"/></collection> 
    1313<collection name="dataSets"><reference ref_id="1_1"/></collection> 
    1414</item> 
    15 <item id="4_1" class="http://www.flymine.org/model/genomic#ProteinDomain"> 
     15<item id="5_1" class="http://www.flymine.org/model/genomic#ProteinDomain"> 
    1616<attribute name="primaryIdentifier" value="PF00089"/> 
    1717<collection name="dataSets"><reference ref_id="1_1"/></collection> 
     
    2828<reference name="dataSource" ref_id="0_1"/> 
    2929</item> 
     30<item id="4_1" class="http://www.flymine.org/model/genomic#Synonym"> 
     31<attribute name="type" value="accession"/> 
     32<attribute name="value" value="Q8IQ89"/> 
     33<reference name="source" ref_id="0_1"/> 
     34<reference name="subject" ref_id="3_1"/> 
     35<collection name="dataSets"><reference ref_id="1_1"/></collection> 
     36</item> 
    3037</items> 
  • trunk/bio/sources/protein_structure/test/src/org/intermine/bio/dataconversion/ProteinStructureDataConverterTest.java

    r15840 r16240  
    4747        converter.close(); 
    4848        // uncomment to create a new target items files 
    49         // writeItemsFile(itemWriter.getItems(), "/tmp/ProteinStructureConverterTest_tgt.xml"); 
     49        //writeItemsFile(itemWriter.getItems(), "ProteinStructureConverterTest_tgt.xml"); 
    5050        Set expected = readItemSet("ProteinStructureConverterTest_tgt.xml"); 
    5151        assertEquals(expected, itemWriter.getItems());