Changeset 16242

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

in biogrid, create synonyms for genes

Files:

Legend:

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

    r16065 r16242  
    2121import java.util.Stack; 
    2222 
     23import org.apache.commons.lang.StringUtils; 
    2324import org.apache.log4j.Logger; 
    2425import org.intermine.dataconversion.ItemWriter; 
     
    4647    private static Map<String, String> masterList = new HashMap<String, String>(); 
    4748    protected IdResolverFactory resolverFactory; 
     49    private Map<String, Item> synonyms = new HashMap<String, Item>(); 
    4850 
    4951    /** 
     
    189191                        String identifier = attrs.getValue("id"); 
    190192                        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                        } 
    192198                    } 
    193199                } 
     
    310316                        Item gene = null; 
    311317                        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                            } 
    313324                        } 
    314325                        if (gene != null) { 
     
    450461        } 
    451462 
    452         private Item getGene(String taxonId, String id)
     463        private Item getGene(String taxonId, String id) throws ObjectStoreException
    453464            String identifier = id; 
    454465            // for Drosophila attempt to update to a current gene identifier 
     
    469480                item.setAttribute("primaryIdentifier", identifier); 
    470481                genes.put(identifier, item); 
     482                createSynonym(item.getIdentifier(), "identifier", identifier); 
    471483            } 
    472484            return item; 
     
    635647        } 
    636648    } 
     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 
    637667} 
  • trunk/bio/sources/biogrid/resources/biogrid_keys.properties

    r14664 r16242  
    44DataSource=key_name 
    55Gene=key_primaryidentifier 
     6Synonym=key_synonym 
  • trunk/bio/sources/biogrid/test/resources/BioGridConverterTest_tgt.xml

    r16070 r16242  
    55  <item id="4_1" class="http://www.flymine.org/model/genomic#Gene"> 
    66    <attribute name="primaryIdentifier" value="FBgn001"/> 
    7     <reference name="organism" ref_id="5_1"/> 
     7    <reference name="organism" ref_id="6_1"/> 
    88    <collection name="dataSets"><reference ref_id="1_1"/></collection> 
    99  </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"> 
    1111    <attribute name="geneRole" value="bait"/> 
    1212    <attribute name="shortName" value="FBgn0000001_FBgn0000002"/> 
     
    1717    <collection name="interactingGenes"><reference ref_id="4_2"/></collection> 
    1818  </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"> 
    2020    <attribute name="geneRole" value="prey"/> 
    2121    <attribute name="shortName" value="FBgn0000002_FBgn0000001"/> 
     
    3131  <item id="4_2" class="http://www.flymine.org/model/genomic#Gene"> 
    3232    <attribute name="primaryIdentifier" value="FBgn002"/> 
    33     <reference name="organism" ref_id="5_1"/> 
     33    <reference name="organism" ref_id="6_1"/> 
    3434    <collection name="dataSets"><reference ref_id="1_1"/></collection> 
    3535  </item> 
     
    3838    <reference name="dataSource" ref_id="0_1"/> 
    3939  </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"> 
    4141    <attribute name="taxonId" value="7227"/> 
    4242  </item> 
     
    4646    <reference name="publication" ref_id="3_1"/> 
    4747  </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> 
    4862</items> 
  • trunk/bio/sources/biogrid/test/src/org/intermine/bio/dataconversion/BioGridConverterTest.java

    r15917 r16242  
    4949 
    5050        // 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"); 
    5252 
    5353        Set expected = readItemSet("BioGridConverterTest_tgt.xml");