Changeset 16240
- Timestamp:
- 16/07/08 14:27:49 (1 month ago)
- Files:
-
- trunk/bio/sources/protein_structure/main/src/org/intermine/bio/dataconversion/ProteinStructureDataConverter.java (modified) (5 diffs)
- trunk/bio/sources/protein_structure/test/resources/ProteinStructureConverterTest_tgt.xml (modified) (2 diffs)
- trunk/bio/sources/protein_structure/test/src/org/intermine/bio/dataconversion/ProteinStructureDataConverterTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bio/sources/protein_structure/main/src/org/intermine/bio/dataconversion/ProteinStructureDataConverter.java
r16018 r16240 22 22 import java.util.Stack; 23 23 24 import org.apache.commons.lang.StringUtils; 24 25 import org.apache.log4j.Logger; 25 26 import org.intermine.InterMineException; … … 46 47 private final Map<String, String> proteinMap = new HashMap<String, String>(); 47 48 private String parentDir; 49 private Map<String, Item> synonyms = new HashMap<String, Item>(); 48 50 49 51 /** … … 240 242 } 241 243 242 private String getProtein(String identifier) {244 private String getProtein(String identifier) throws ObjectStoreException { 243 245 String proteinIdentifier = proteinMap.get(identifier); 244 246 if (proteinIdentifier == null) { … … 246 248 protein.setAttribute("primaryAccession", identifier); 247 249 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); 253 252 return protein.getIdentifier(); 254 253 } … … 304 303 } 305 304 } 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 } 306 323 } trunk/bio/sources/protein_structure/test/resources/ProteinStructureConverterTest_tgt.xml
r16018 r16240 9 9 <attribute name="start" value="66"/> 10 10 <attribute name="technique" value="Computer prediction"/> 11 <reference name="proteinDomain" ref_id=" 4_1"/>11 <reference name="proteinDomain" ref_id="5_1"/> 12 12 <collection name="proteins"><reference ref_id="3_1"/></collection> 13 13 <collection name="dataSets"><reference ref_id="1_1"/></collection> 14 14 </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"> 16 16 <attribute name="primaryIdentifier" value="PF00089"/> 17 17 <collection name="dataSets"><reference ref_id="1_1"/></collection> … … 28 28 <reference name="dataSource" ref_id="0_1"/> 29 29 </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> 30 37 </items> trunk/bio/sources/protein_structure/test/src/org/intermine/bio/dataconversion/ProteinStructureDataConverterTest.java
r15840 r16240 47 47 converter.close(); 48 48 // uncomment to create a new target items files 49 // writeItemsFile(itemWriter.getItems(), "/tmp/ProteinStructureConverterTest_tgt.xml");49 //writeItemsFile(itemWriter.getItems(), "ProteinStructureConverterTest_tgt.xml"); 50 50 Set expected = readItemSet("ProteinStructureConverterTest_tgt.xml"); 51 51 assertEquals(expected, itemWriter.getItems());
