Changeset 16255
- Timestamp:
- 18/07/08 10:13:09 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/bio/sources/biogrid/main/src/org/intermine/bio/dataconversion/BioGridConverter.java
r16242 r16255 21 21 import java.util.Stack; 22 22 23 import org.apache.commons.lang.StringUtils;24 23 import org.apache.log4j.Logger; 25 24 import org.intermine.dataconversion.ItemWriter; … … 47 46 private static Map<String, String> masterList = new HashMap<String, String>(); 48 47 protected IdResolverFactory resolverFactory; 49 private Map<String, Item> synonyms = new HashMap<String, Item>();50 48 51 49 /** … … 191 189 String identifier = attrs.getValue("id"); 192 190 geneIdsToIdentifiers.put(geneId, identifier); 193 try { 194 getGene(organismTaxonId, identifier); 195 } catch (ObjectStoreException e) { 196 throw new RuntimeException("error while storing: " + identifier, e); 197 } 191 getGene(organismTaxonId, identifier); 198 192 } 199 193 } … … 316 310 Item gene = null; 317 311 if (identifier != null) { 318 try { 319 gene = getGene(organismTaxonId, identifier); 320 } catch (ObjectStoreException e) { 321 throw new RuntimeException("error while storing: " 322 + identifier, e); 323 } 312 gene = getGene(organismTaxonId, identifier); 324 313 } 325 314 if (gene != null) { … … 461 450 } 462 451 463 private Item getGene(String taxonId, String id) throws ObjectStoreException{452 private Item getGene(String taxonId, String id) { 464 453 String identifier = id; 465 454 // for Drosophila attempt to update to a current gene identifier … … 480 469 item.setAttribute("primaryIdentifier", identifier); 481 470 genes.put(identifier, item); 482 createSynonym(item.getIdentifier(), "identifier", identifier);483 471 } 484 472 return item; … … 647 635 } 648 636 } 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 667 637 } trunk/bio/sources/biogrid/test/resources/BioGridConverterTest_tgt.xml
r16242 r16255 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=" 6_1"/>7 <reference name="organism" ref_id="5_1"/> 8 8 <collection name="dataSets"><reference ref_id="1_1"/></collection> 9 9 </item> 10 <item id=" 7_1" class="http://www.flymine.org/model/genomic#GeneticInteraction">10 <item id="6_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=" 7_2" class="http://www.flymine.org/model/genomic#GeneticInteraction">19 <item id="6_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=" 6_1"/>33 <reference name="organism" ref_id="5_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=" 6_1" class="http://www.flymine.org/model/genomic#Organism">40 <item id="5_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>62 48 </items>
