Changeset 16242
- Timestamp:
- 16/07/08 14:43:09 (1 month ago)
- Files:
-
- trunk/bio/sources/biogrid/main/src/org/intermine/bio/dataconversion/BioGridConverter.java (modified) (7 diffs)
- trunk/bio/sources/biogrid/resources/biogrid_keys.properties (modified) (1 diff)
- trunk/bio/sources/biogrid/test/resources/BioGridConverterTest_tgt.xml (modified) (5 diffs)
- trunk/bio/sources/biogrid/test/src/org/intermine/bio/dataconversion/BioGridConverterTest.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bio/sources/biogrid/main/src/org/intermine/bio/dataconversion/BioGridConverter.java
r16065 r16242 21 21 import java.util.Stack; 22 22 23 import org.apache.commons.lang.StringUtils; 23 24 import org.apache.log4j.Logger; 24 25 import org.intermine.dataconversion.ItemWriter; … … 46 47 private static Map<String, String> masterList = new HashMap<String, String>(); 47 48 protected IdResolverFactory resolverFactory; 49 private Map<String, Item> synonyms = new HashMap<String, Item>(); 48 50 49 51 /** … … 189 191 String identifier = attrs.getValue("id"); 190 192 geneIdsToIdentifiers.put(geneId, identifier); 191 getGene(organismTaxonId, identifier); 193 try { 194 getGene(organismTaxonId, identifier); 195 } catch (ObjectStoreException e) { 196 throw new RuntimeException("error while storing: " + identifier, e); 197 } 192 198 } 193 199 } … … 310 316 Item gene = null; 311 317 if (identifier != null) { 312 gene = getGene(organismTaxonId, identifier); 318 try { 319 gene = getGene(organismTaxonId, identifier); 320 } catch (ObjectStoreException e) { 321 throw new RuntimeException("error while storing: " 322 + identifier, e); 323 } 313 324 } 314 325 if (gene != null) { … … 450 461 } 451 462 452 private Item getGene(String taxonId, String id) {463 private Item getGene(String taxonId, String id) throws ObjectStoreException { 453 464 String identifier = id; 454 465 // for Drosophila attempt to update to a current gene identifier … … 469 480 item.setAttribute("primaryIdentifier", identifier); 470 481 genes.put(identifier, item); 482 createSynonym(item.getIdentifier(), "identifier", identifier); 471 483 } 472 484 return item; … … 635 647 } 636 648 } 649 private Item createSynonym(String subjectId, String type, String value) 650 throws ObjectStoreException { 651 String key = subjectId + type + value; 652 if (StringUtils.isEmpty(value)) { 653 return null; 654 } 655 if (!synonyms.containsKey(key)) { 656 Item syn = createItem("Synonym"); 657 syn.setReference("subject", subjectId); 658 syn.setAttribute("type", type); 659 syn.setAttribute("value", value); 660 synonyms.put(key, syn); 661 store(syn); 662 return syn; 663 } 664 return null; 665 } 666 637 667 } trunk/bio/sources/biogrid/resources/biogrid_keys.properties
r14664 r16242 4 4 DataSource=key_name 5 5 Gene=key_primaryidentifier 6 Synonym=key_synonym trunk/bio/sources/biogrid/test/resources/BioGridConverterTest_tgt.xml
r16070 r16242 5 5 <item id="4_1" class="http://www.flymine.org/model/genomic#Gene"> 6 6 <attribute name="primaryIdentifier" value="FBgn001"/> 7 <reference name="organism" ref_id=" 5_1"/>7 <reference name="organism" ref_id="6_1"/> 8 8 <collection name="dataSets"><reference ref_id="1_1"/></collection> 9 9 </item> 10 <item id=" 6_1" class="http://www.flymine.org/model/genomic#GeneticInteraction">10 <item id="7_1" class="http://www.flymine.org/model/genomic#GeneticInteraction"> 11 11 <attribute name="geneRole" value="bait"/> 12 12 <attribute name="shortName" value="FBgn0000001_FBgn0000002"/> … … 17 17 <collection name="interactingGenes"><reference ref_id="4_2"/></collection> 18 18 </item> 19 <item id=" 6_2" class="http://www.flymine.org/model/genomic#GeneticInteraction">19 <item id="7_2" class="http://www.flymine.org/model/genomic#GeneticInteraction"> 20 20 <attribute name="geneRole" value="prey"/> 21 21 <attribute name="shortName" value="FBgn0000002_FBgn0000001"/> … … 31 31 <item id="4_2" class="http://www.flymine.org/model/genomic#Gene"> 32 32 <attribute name="primaryIdentifier" value="FBgn002"/> 33 <reference name="organism" ref_id=" 5_1"/>33 <reference name="organism" ref_id="6_1"/> 34 34 <collection name="dataSets"><reference ref_id="1_1"/></collection> 35 35 </item> … … 38 38 <reference name="dataSource" ref_id="0_1"/> 39 39 </item> 40 <item id=" 5_1" class="http://www.flymine.org/model/genomic#Organism">40 <item id="6_1" class="http://www.flymine.org/model/genomic#Organism"> 41 41 <attribute name="taxonId" value="7227"/> 42 42 </item> … … 46 46 <reference name="publication" ref_id="3_1"/> 47 47 </item> 48 <item id="5_1" class="http://www.flymine.org/model/genomic#Synonym"> 49 <attribute name="type" value="identifier"/> 50 <attribute name="value" value="FBgn001"/> 51 <reference name="source" ref_id="0_1"/> 52 <reference name="subject" ref_id="4_1"/> 53 <collection name="dataSets"><reference ref_id="1_1"/></collection> 54 </item> 55 <item id="5_2" class="http://www.flymine.org/model/genomic#Synonym"> 56 <attribute name="type" value="identifier"/> 57 <attribute name="value" value="FBgn002"/> 58 <reference name="source" ref_id="0_1"/> 59 <reference name="subject" ref_id="4_2"/> 60 <collection name="dataSets"><reference ref_id="1_1"/></collection> 61 </item> 48 62 </items> trunk/bio/sources/biogrid/test/src/org/intermine/bio/dataconversion/BioGridConverterTest.java
r15917 r16242 49 49 50 50 // uncomment to write out a new target items file 51 // writeItemsFile(itemWriter.getItems(), "/tmp/biogrid-tgt-items.xml");51 //writeItemsFile(itemWriter.getItems(), "biogrid-tgt-items.xml"); 52 52 53 53 Set expected = readItemSet("BioGridConverterTest_tgt.xml");
