Changeset 20738
- Timestamp:
- 26/02/10 16:10:04 (2 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
bio/postprocess/main/src/org/intermine/bio/postprocess/CreateFlankingRegions.java (modified) (3 diffs)
-
bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/FlyBaseProcessor.java (modified) (3 diffs)
-
bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/ModEncodeFeatureProcessor.java (modified) (20 diffs)
-
bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/ModEncodeMetaDataProcessor.java (modified) (117 diffs)
-
bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/WormBaseProcessor.java (modified) (4 diffs)
-
bio/sources/flymine/flyatlas/main/src/org/intermine/bio/dataconversion/FlyAtlasConverter.java (modified) (2 diffs)
-
intermine/integrate/main/src/org/intermine/xml/full/Item.java (modified) (3 diffs)
-
intermine/objectstore/main/src/org/intermine/util/StringUtil.java (modified) (1 diff)
-
intermine/pathquery/main/src/org/intermine/pathquery/PathQuery.java (modified) (3 diffs)
-
intermine/web/main/src/org/intermine/web/logic/session/SessionMethods.java (modified) (1 diff)
-
intermine/web/main/src/org/intermine/web/struts/HtmlHeadController.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bio/postprocess/main/src/org/intermine/bio/postprocess/CreateFlankingRegions.java
r20462 r20738 16 16 import java.util.Map; 17 17 18 import org.apache.commons.lang.StringUtils; 18 19 import org.apache.log4j.Logger; 19 20 import org.intermine.bio.util.BioQueries; … … 30 31 import org.intermine.objectstore.query.ResultsRow; 31 32 import org.intermine.util.DynamicUtil; 32 import org.intermine.util.StringUtil;33 33 34 34 /** … … 134 134 // submissions. This should work by DataSet but WormBase chado isn't setting a DataSet 135 135 // correctly 136 if (StringUtil .isEmpty(gene.getSymbol())) {136 if (StringUtils.isEmpty(gene.getSymbol())) { 137 137 return; 138 138 } -
trunk/bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/FlyBaseProcessor.java
r20679 r20738 39 39 import org.intermine.objectstore.ObjectStoreException; 40 40 import org.intermine.util.IntPresentSet; 41 import org.intermine.util.StringUtil;42 41 import org.intermine.util.XmlUtil; 43 42 import org.intermine.xml.full.Item; … … 1742 1741 // make a synonym for the protein we're about to discard 1743 1742 if (protein != null) { 1744 if ( !StringUtil.isEmpty(uniqueName)1743 if (StringUtils.isNotEmpty(uniqueName) 1745 1744 && !protein.getExistingSynonyms().contains(uniqueName)) { 1746 1745 Item synonym = createSynonym(protein, "identifier", uniqueName, true, … … 1748 1747 store(synonym); 1749 1748 } 1750 if ( !StringUtil.isEmpty(name)1749 if (StringUtils.isNotEmpty(name) 1751 1750 && !protein.getExistingSynonyms().contains(name)) { 1752 1751 Item synonym = createSynonym(protein, "name", name, false, null); -
trunk/bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/ModEncodeFeatureProcessor.java
r20658 r20738 26 26 import org.apache.commons.collections.keyvalue.MultiKey; 27 27 import org.apache.commons.collections.map.MultiKeyMap; 28 import org.apache.commons.lang.StringUtils; 28 29 import org.apache.log4j.Logger; 29 30 import org.intermine.bio.chado.config.ConfigAction; … … 31 32 import org.intermine.bio.util.OrganismData; 32 33 import org.intermine.objectstore.ObjectStoreException; 33 import org.intermine.util.StringUtil;34 34 import org.intermine.util.TypeUtil; 35 35 import org.intermine.xml.full.Attribute; … … 50 50 private final List<Integer> dataList; 51 51 private final String title; 52 52 53 53 private Set<String> commonFeatureInterMineTypes = new HashSet<String>(); 54 54 55 55 private static final String SUBFEATUREID_TEMP_TABLE_NAME = "modmine_subfeatureid_temp"; 56 57 56 58 57 // feature type to query from the feature table … … 91 90 * i.e. the labItemIdentifier 92 91 * @param dataList the list of data ids to be used in the subquery 93 * @param title the title 92 * @param title the title 94 93 */ 95 94 … … 102 101 this.dataList = dataList; 103 102 this.title = title; 104 103 105 104 for (String chromosomeType : getChromosomeFeatureTypes()) { 106 105 commonFeatureInterMineTypes.add( … … 184 183 // (and merge the methods) 185 184 // also: add match to query and do everything here 186 185 187 186 // process indirect locations via match features and featureloc feature<->match<->feature 188 187 ResultSet matchLocRes = getMatchLocResultSet(connection); … … 199 198 processLocationTable(connection, matchTypeLocRes); 200 199 } 201 200 202 201 // adding scores 203 202 processFeatureScores(connection); … … 207 206 /** 208 207 * Method to set the source for gene 209 * for modencode datasources it will add the title 208 * for modencode datasources it will add the title 210 209 * @param imObjectId the im object id 211 210 * @param dataSourceName the data source … … 214 213 */ 215 214 @Override 216 protected void setGeneSource(Integer imObjectId, String dataSourceName) 215 protected void setGeneSource(Integer imObjectId, String dataSourceName) 217 216 throws ObjectStoreException { 218 217 String source = dataSourceName + "-" + title; … … 236 235 } 237 236 238 private List<String> getMatchTypes(Connection connection) throws SQLException, 239 ObjectStoreException { 237 private List<String> getMatchTypes(Connection connection) throws SQLException { 240 238 List<String> types = new ArrayList<String>(); 241 239 ResultSet res = getMatchTypesResultSet(connection); … … 250 248 251 249 /** 252 * Return the match types, used to determine which additional query to run 250 * Return the match types, used to determine which additional query to run 253 251 * This is a protected method so that it can be overriden for testing 254 252 * @param connection the db connection … … 264 262 ResultSet res = stmt.executeQuery(query); 265 263 LOG.debug("QUERY TIME feature match types: " + (System.currentTimeMillis() - bT)); 266 return res; 267 } 268 269 270 /** 271 * Return the interesting feature (EST, UST, RST, other?) matches 264 return res; 265 } 266 267 268 /** 269 * Return the interesting feature (EST, UST, RST, other?) matches 272 270 * from the featureloc and feature tables. 273 * 271 * 274 272 * feature<->featureloc<->match_feature<->featureloc<->feature 275 273 * This is a protected method so that it can be overriden for testing … … 306 304 return res; 307 305 } 308 306 309 307 310 308 /** … … 369 367 Thread.currentThread().setContextClassLoader(currentClassLoader); 370 368 } 371 } else { 372 DataSetStoreHook.setDataSets(getModel(), item, dataSetIdentifier, dataSourceIdentifier); 373 } 374 } 375 376 369 } 370 DataSetStoreHook.setDataSets(getModel(), item, dataSetIdentifier, dataSourceIdentifier); 371 } 372 373 377 374 /** 378 375 * {@inheritDoc} … … 481 478 if (uniqueName.startsWith("chr")) { 482 479 // this is to fix some data problem with sub 146 in modmine 483 // where there are duplicated chromosome_arm features, with 480 // where there are duplicated chromosome_arm features, with 484 481 // and without a 'chr' prefix (e.g. 3R and chr3R) 485 482 // The chr ones are not the location for any other feature. … … 489 486 } 490 487 Item feature = getChadoDBConverter().createItem(realInterMineType); 491 488 492 489 return feature; 493 490 } … … 589 586 String name = fdat.getChadoFeatureName(); 590 587 String type = fdat.getInterMineType(); 591 588 592 589 if (identifier.equalsIgnoreCase(uniqueName)) { 593 590 if (type.equalsIgnoreCase(CHROMOSOME)) { … … 600 597 } 601 598 } 602 603 // Piano submissions have Gene: and Transcript: 599 600 // Piano submissions have Gene: and Transcript: 604 601 // in front of gene and transcript identifiers 605 602 if (type.equalsIgnoreCase("Gene")) { … … 610 607 } 611 608 612 if (StringUtil .isEmpty(identifier)) {613 if (StringUtil .isEmpty(name)) {609 if (StringUtils.isEmpty(identifier)) { 610 if (StringUtils.isEmpty(name)) { 614 611 String fixedName = uniqueName.substring(uniqueName.lastIndexOf('.') + 1); 615 612 return fixedName; … … 618 615 } 619 616 } 620 return identifier; 621 } 622 617 return identifier; 618 } 619 623 620 private void processFeatureScores(Connection connection) throws SQLException, 624 621 ObjectStoreException { -
trunk/bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/ModEncodeMetaDataProcessor.java
r20734 r20738 78 78 new HashMap<Integer, AppliedData>(); 79 79 80 81 80 // project/lab/experiment/submission maps 82 81 // -------------------------------------- … … 104 103 private Map<Integer, String> protocolItemIds = new HashMap<Integer, String>(); 105 104 private Map<String, Integer> protocolItemToObjectId = new HashMap<String, Integer>(); 106 105 107 106 private Map<Integer, Integer> publicationIdMap = new HashMap<Integer, Integer>(); 108 107 private Map<Integer, String> publicationIdRefMap = new HashMap<Integer, String>(); 109 110 111 108 109 110 112 111 private Map<Integer, String> protocolTypesMap = new HashMap<Integer, String>(); 113 112 private Map<Integer, Integer> appliedProtocolIdMap = new HashMap<Integer, Integer>(); … … 139 138 private IdResolverFactory wormResolverFactory = null; 140 139 private Map<String, String> geneToItemIdentifier = new HashMap<String, String>(); 141 140 142 141 private Map<DatabaseRecordKey, String> dbRecords = new HashMap<DatabaseRecordKey, String>(); 143 142 144 143 145 144 private static class SubmissionDetails 146 145 { … … 198 197 } 199 198 200 201 199 200 202 201 /** 203 202 * Create a new ChadoProcessor object … … 233 232 setSubmissionExperimetRefs(connection); 234 233 setDAGRefs(connection); 235 234 236 235 // create DatabaseRecords where necessary for each submission 237 236 createDatabaseRecords(connection); … … 250 249 } 251 250 252 251 253 252 /** 254 253 * … … 307 306 String queryList = StringUtil.join(thisSubmissionDataIds, ","); 308 307 processDataFeatureTable(connection, subFeatureMap, chadoExperimentId, queryList); 309 308 310 309 // read any genes that have been created so we can re-use the same item identifiers 311 310 // when creating antibody/strain target genes later … … 315 314 } 316 315 317 private void extractGenesFromSubFeatureMap(ModEncodeFeatureProcessor processor, 316 private void extractGenesFromSubFeatureMap(ModEncodeFeatureProcessor processor, 318 317 Map<Integer, FeatureData> subFeatureMap) { 319 318 for (FeatureData fData : subFeatureMap.values()) { … … 324 323 } 325 324 } 326 325 327 326 /** 328 327 * @param connection … … 343 342 Integer dataId = new Integer(res.getInt("data_id")); 344 343 Integer featureId = new Integer(res.getInt("feature_id")); 345 344 346 345 FeatureData featureData = featureMap.get(featureId); 347 346 if (featureData == null) { … … 355 354 // TODO: it needs correction: here stores only the last submission reference. 356 355 Integer featureObjectId = featureData.getIntermineObjectId(); 357 356 358 357 collection = new ReferenceList(); 359 358 collection.setName("submissions"); … … 1059 1058 value = value.substring(value.indexOf(':') + 1); 1060 1059 } 1061 1060 1062 1061 Item pub = getChadoDBConverter().createItem("Publication"); 1063 1062 pub.setAttribute(fieldName, value); 1064 1063 Integer intermineObjectId = getChadoDBConverter().store(pub); 1065 1064 1066 1065 publicationIdMap.put(submissionId, intermineObjectId); 1067 1066 publicationIdRefMap.put(submissionId, pub.getIdentifier()); 1068 1067 continue; 1069 1068 } 1070 1069 1071 1070 setAttribute(submissionMap.get(submissionId).interMineObjectId, fieldName, value); 1072 1071 count++; … … 1100 1099 * ========================== 1101 1100 * 1102 * 1101 * 1103 1102 * @param connection 1104 1103 * @throws SQLException … … 1115 1114 ExperimentalFactor ef = null; 1116 1115 String name = null; 1117 1116 1118 1117 while (res.next()) { 1119 1118 Integer submissionId = new Integer(res.getInt("experiment_id")); 1120 1119 Integer rank = new Integer(res.getInt("rank")); 1121 1120 String value = res.getString("value"); 1122 1121 1123 1122 // the data is alternating between EF types and names, in order. 1124 1123 if (submissionId != prevSub) { … … 1150 1149 } 1151 1150 res.close(); 1152 LOG.info("created " + count + " experimental factors"); 1151 LOG.info("created " + count + " experimental factors"); 1153 1152 LOG.info("PROCESS TIME experimental factors: " + (System.currentTimeMillis() - bT)); 1154 1153 } … … 1208 1207 } 1209 1208 1210 1209 1211 1210 private String createProtocol(Integer chadoId, String name, String description, String wikiLink, 1212 1211 Integer version) throws ObjectStoreException { … … 1219 1218 protocol.setAttribute("version", "" + version); 1220 1219 Integer intermineObjectId = getChadoDBConverter().store(protocol); 1221 1222 1220 1221 1223 1222 protocolItemId = protocol.getIdentifier(); 1224 1223 protocolItemToObjectId.put(protocolItemId, intermineObjectId); … … 1232 1231 return protocolItemToObjectId.get(protocolItemIds.get(chadoId)); 1233 1232 } 1234 1235 1233 1234 1236 1235 /** 1237 1236 * Return the rows needed from the protocol table. … … 1550 1549 // first value in the list of synonyms is the 'preferred' value 1551 1550 private static String[][] synonyms = new String[][]{ 1552 new String[] {"developmental stage", "stage", 1551 new String[] {"developmental stage", "stage", 1553 1552 "developmental_stage", "dev stage", "devstage"}, 1554 1553 new String[] {"strain", "strain_or_line"}, … … 1583 1582 return unified; 1584 1583 } 1585 1586 1584 1585 1587 1586 private class SubmissionReference 1588 1587 { … … 1594 1593 private String dataValue; 1595 1594 } 1596 1595 1597 1596 // process new query 1598 1597 // get DCC id … … 1622 1621 Integer lastDataId = new Integer(-1); 1623 1622 Map<String, SubmissionProperty> props = new HashMap <String, SubmissionProperty>(); 1624 1625 Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes = 1623 1624 Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes = 1626 1625 new HashMap<Integer, Map<String, List<SubmissionProperty>>>(); 1627 1626 1628 1627 submissionRefs = new HashMap<Integer, SubmissionReference>(); 1629 1628 1630 1629 while (res.next()) { 1631 1630 Integer dataId = new Integer(res.getInt("data_id")); … … 1638 1637 String attValue = res.getString("att_value"); 1639 1638 String attDbxref = res.getString("att_dbxref"); 1640 1639 1641 1640 Integer submissionId = dataSubmissionMap.get(dataId); 1642 1641 LOG.debug("DCC fetch: " + submissionId + ", " + dccIdMap.get(submissionId)); 1643 1642 String dccId = dccIdMap.get(submissionId); 1644 1643 1645 writer.write(dccId + comma + dataHeading + comma + dataName + comma 1646 + wikiPageUrl + comma + cvTerm + comma + attHeading + comma + attName 1644 writer.write(dccId + comma + dataHeading + comma + dataName + comma 1645 + wikiPageUrl + comma + cvTerm + comma + attHeading + comma + attName 1647 1646 + comma + attValue + comma + attDbxref + System.getProperty("line.separator")); 1648 1647 … … 1655 1654 Integer referencedSubId = getSubmissionIdFromDccId(attValue); 1656 1655 if (referencedSubId != null) { 1657 SubmissionReference subRef = 1656 SubmissionReference subRef = 1658 1657 new SubmissionReference(referencedSubId, wikiPageUrl); 1659 1658 submissionRefs.put(submissionId, subRef); … … 1667 1666 buildSubProperty = null; 1668 1667 } else { 1669 buildSubProperty = 1668 buildSubProperty = 1670 1669 new SubmissionProperty(getPreferredSynonym(dataName), wikiPageUrl); 1671 1670 props.put(wikiPageUrl, buildSubProperty); … … 1687 1686 // properties here 1688 1687 addSubmissionPropsFromCharacteristics(subToTypes, connection); 1689 1688 1690 1689 // some submissions use reagents created in reference submissions, find the properties 1691 1690 // of the reagents and add to referencing submission 1692 1691 addSubmissionPropsFromReferencedSubmissions(subToTypes, props, submissionRefs); 1693 1692 1694 1693 // create and store properties of submission 1695 1694 for (Integer submissionId : subToTypes.keySet()) { 1696 1695 Integer storedSubmissionId = submissionMap.get(submissionId).interMineObjectId; 1697 1696 1698 1697 Map<String, List<SubmissionProperty>> typeToProp = subToTypes.get(submissionId); 1699 1698 1700 1699 String dccId = dccIdMap.get(submissionId); 1701 1700 1702 1701 ExperimentalFactor ef = submissionEFMap.get(submissionId); 1703 1702 if (ef == null) { … … 1705 1704 continue; 1706 1705 } 1707 Set<String> exFactorNames = unifyFactorNames(ef.efNames); 1706 Set<String> exFactorNames = unifyFactorNames(ef.efNames); 1708 1707 LOG.info("PROPERTIES " + dccId + " typeToProp keys: " + typeToProp.keySet()); 1709 1708 1710 1709 List<Item> allPropertyItems = new ArrayList<Item>(); 1711 1710 1712 1711 // DEVELOPMENTAL STAGE 1713 1712 List<Item> devStageItems = new ArrayList<Item>(); 1714 devStageItems.addAll(createFromWikiPage(dccId, "DevelopmentalStage", typeToProp, 1713 devStageItems.addAll(createFromWikiPage(dccId, "DevelopmentalStage", typeToProp, 1715 1714 makeLookupList("developmental stage"))); 1716 1715 if (devStageItems.isEmpty()) { … … 1724 1723 })); 1725 1724 if (!devStageItems.isEmpty()) { 1726 } 1725 } 1727 1726 } 1728 1727 storeSubmissionCollection(storedSubmissionId, "developmentalStages", devStageItems); … … 1731 1730 exFactorNames.remove("developmental stage"); 1732 1731 } 1733 allPropertyItems.addAll(devStageItems); 1734 1732 allPropertyItems.addAll(devStageItems); 1733 1735 1734 // STRAIN 1736 1735 List<Item> strainItems = new ArrayList<Item>(); 1737 1736 strainItems.addAll(createFromWikiPage( 1738 1737 dccId, "Strain", typeToProp, makeLookupList("strain"))); 1739 1738 1740 1739 storeSubmissionCollection(storedSubmissionId, "strains", strainItems); 1741 1740 if (!strainItems.isEmpty() && exFactorNames.contains("strain")) { … … 1743 1742 exFactorNames.remove("strain"); 1744 1743 } 1745 allPropertyItems.addAll(strainItems); 1746 1747 1744 allPropertyItems.addAll(strainItems); 1745 1746 1748 1747 // ARRAY 1749 1748 List<Item> arrayItems = new ArrayList<Item>(); … … 1757 1756 })); 1758 1757 if (!arrayItems.isEmpty()) { 1759 LOG.debug("Attribute found in other wiki pages: " 1760 + dccId + " ARRAY "); 1758 LOG.debug("Attribute found in other wiki pages: " 1759 + dccId + " ARRAY "); 1761 1760 } 1762 1761 } … … 1766 1765 exFactorNames.remove("array"); 1767 1766 } 1768 allPropertyItems.addAll(arrayItems); 1769 1767 allPropertyItems.addAll(arrayItems); 1768 1770 1769 // CELL LINE 1771 1770 List<Item> lineItems = new ArrayList<Item>(); 1772 lineItems.addAll(createFromWikiPage(dccId, "CellLine", typeToProp, 1771 lineItems.addAll(createFromWikiPage(dccId, "CellLine", typeToProp, 1773 1772 makeLookupList("cell line"))); 1774 1773 storeSubmissionCollection(storedSubmissionId, "cellLines", lineItems); … … 1777 1776 exFactorNames.remove("cell line"); 1778 1777 } 1779 allPropertyItems.addAll(lineItems); 1780 1778 allPropertyItems.addAll(lineItems); 1779 1781 1780 // RNAi REAGENT 1782 1781 List<Item> reagentItems = new ArrayList<Item>(); 1783 reagentItems.addAll(createFromWikiPage(dccId, "SubmissionProperty", typeToProp, 1782 reagentItems.addAll(createFromWikiPage(dccId, "SubmissionProperty", typeToProp, 1784 1783 makeLookupList("dsRNA"))); 1785 1784 if (!reagentItems.isEmpty() && exFactorNames.contains("RNAi reagent")) { … … 1787 1786 exFactorNames.remove("RNAi reagent"); 1788 1787 } 1789 allPropertyItems.addAll(reagentItems); 1790 1788 allPropertyItems.addAll(reagentItems); 1789 1791 1790 // ANTIBODY 1792 1791 List<Item> antibodyItems = new ArrayList<Item>(); 1793 antibodyItems.addAll(createFromWikiPage(dccId, "Antibody", typeToProp, 1792 antibodyItems.addAll(createFromWikiPage(dccId, "Antibody", typeToProp, 1794 1793 makeLookupList("antibody"))); 1795 1794 if (antibodyItems.isEmpty()) { … … 1800 1799 })); 1801 1800 if (!antibodyItems.isEmpty()) { 1802 LOG.debug("Attribute found in other wiki pages: " 1803 + dccId + " ANTIBODY "); 1801 LOG.debug("Attribute found in other wiki pages: " 1802 + dccId + " ANTIBODY "); 1804 1803 } 1805 1804 } … … 1809 1808 exFactorNames.remove("antibody"); 1810 1809 } 1811 allPropertyItems.addAll(antibodyItems); 1812 1813 1810 allPropertyItems.addAll(antibodyItems); 1811 1812 1814 1813 // TISSUE 1815 1814 List<Item> tissueItems = new ArrayList<Item>(); … … 1824 1823 })); 1825 1824 if (!tissueItems.isEmpty()) { 1826 LOG.info("Attribute found in other wiki pages: " 1827 + dccId + " TISSUE"); 1828 } 1825 LOG.info("Attribute found in other wiki pages: " 1826 + dccId + " TISSUE"); 1827 } 1829 1828 } 1830 1829 storeSubmissionCollection(storedSubmissionId, "tissues", tissueItems); … … 1833 1832 exFactorNames.remove("tissue"); 1834 1833 } 1835 allPropertyItems.addAll(tissueItems); 1836 1837 1838 1834 allPropertyItems.addAll(tissueItems); 1835 1836 1837 1839 1838 // There may be some other experimental factors that require SubmissionProperty objects 1840 1839 // but don't fall into the categories above. Create them here and set experimental … … 1843 1842 for (String exFactor : extraPropNames) { 1844 1843 List<Item> extraPropItems = new ArrayList<Item>(); 1845 extraPropItems.addAll(lookForAttributesInOtherWikiPages("SubmissionProperty", 1844 extraPropItems.addAll(lookForAttributesInOtherWikiPages("SubmissionProperty", 1846 1845 typeToProp, new String[] {exFactor})); 1847 allPropertyItems.addAll(extraPropItems); 1846 allPropertyItems.addAll(extraPropItems); 1848 1847 createExperimentalFactors(submissionId, exFactor, extraPropItems); 1849 1848 exFactorNames.remove(exFactor); 1850 1849 } 1851 1850 1852 1851 1853 1852 // Store Submission.properties/ SubmissionProperty.submissions 1854 1853 storeSubmissionCollection(storedSubmissionId, "properties", allPropertyItems); 1855 1854 1856 1855 // deal with remaining factor names (e.g. the ones for which we did 1857 1856 // not find a corresponding attribute … … 1859 1858 String type = ef.efTypes.get(exFactor); 1860 1859 createEFItem(submissionId, type, exFactor, null); 1861 } 1860 } 1862 1861 } 1863 1862 LOG.info("PROCESS TIME submission properties: " + (System.currentTimeMillis() - bT)); … … 1865 1864 1866 1865 // Traverse DAG following previous applied protocol links to build a list of all AppliedData 1867 private void findAppliedProtocolsAndDataFromEarlierInDag(Integer startDataId, 1866 private void findAppliedProtocolsAndDataFromEarlierInDag(Integer startDataId, 1868 1867 List<AppliedData> foundAppliedData, List<AppliedProtocol> foundAppliedProtocols) { 1869 1868 AppliedData aData = appliedDataMap.get(startDataId); … … 1871 1870 foundAppliedData.add(aData); 1872 1871 } 1873 1872 1874 1873 for (Integer previousAppliedProtocolId : aData.previousAppliedProtocols) { 1875 1874 AppliedProtocol ap = appliedProtocolMap.get(previousAppliedProtocolId); … … 1881 1880 foundAppliedProtocols); 1882 1881 } 1883 } 1884 } 1885 1886 1887 private void createExperimentalFactors(Integer submissionId, String type, 1882 } 1883 } 1884 1885 1886 private void createExperimentalFactors(Integer submissionId, String type, 1888 1887 Collection<Item> items) throws ObjectStoreException { 1889 1888 for (Item item : items) { 1890 createEFItem(submissionId, type, item.getAttribute("name").getValue(), 1889 createEFItem(submissionId, type, item.getAttribute("name").getValue(), 1891 1890 item.getIdentifier()); 1892 1891 } 1893 1892 } 1894 1895 1893 1894 1896 1895 private void createEFItem(Integer current, String type, 1897 1896 String efName, String propertyIdentifier) throws ObjectStoreException { … … 1916 1915 1917 1916 1918 private void addToSubToTypes(Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes, 1917 private void addToSubToTypes(Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes, 1919 1918 Integer submissionId, SubmissionProperty prop) { 1920 1919 // submissionId -> [type -> SubmissionProperty] … … 1928 1927 subProps = new ArrayList<SubmissionProperty>(); 1929 1928 typeToSubProp.put(prop.type, subProps); 1930 } 1929 } 1931 1930 subProps.add(prop); 1932 1931 } 1933 1934 1932 1933 1935 1934 private void addSubmissionPropsFromCharacteristics( 1936 Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes, 1937 Connection connection) 1935 Map<Integer, Map<String, List<SubmissionProperty>>> subToTypes, 1936 Connection connection) 1938 1937 throws SQLException { 1939 1938 1940 1939 ResultSet res = getAppliedDataCharacteristics(connection); 1941 1940 … … 1946 1945 Integer currentSubId = null; // we need those to attach the property to the correct sub 1947 1946 Integer previousSubId = null; 1948 1947 1949 1948 while (res.next()) { 1950 1949 Integer dataId = new Integer(res.getInt("data_id")); … … 1953 1952 String attValue = res.getString("att_value"); 1954 1953 Integer attDbxref = new Integer(res.getInt("att_dbxref")); 1955 1954 1956 1955 currentSubId = dataSubmissionMap.get(dataId); 1957 1956 1958 LOG.debug("XXX " + currentSubId + ":" + dataId + "|" + attValue + "|" +attDbxref); 1957 LOG.debug("XXX " + currentSubId + ":" + dataId + "|" + attValue 1958 + "|" +attDbxref); 1959 1959 if (attDbxref.intValue() != lastAttDbXref.intValue() || 1960 currentSubId != previousSubId) { 1960 currentSubId != previousSubId) { 1961 1961 // store the last build property if created, type is set only if we found an 1962 1962 // attHeading of Characteristics 1963 1963 // note: dbxref can remain the same in different subs -> or 1964 1964 if (buildSubProperty != null && buildSubProperty.type != null) { 1965 createdProps.put(lastAttDbXref, buildSubProperty); 1965 createdProps.put(lastAttDbXref, buildSubProperty); 1966 1966 addToSubToTypes(subToTypes, previousSubId, buildSubProperty); 1967 1967 } 1968 // set up for next attDbxref 1968 // set up for next attDbxref 1969 1969 if (createdProps.containsKey(attDbxref) && isValidCharacteristic) { 1970 1970 // seen this property before so just add for this submission, don't build again … … 1977 1977 } 1978 1978 } 1979 1979 1980 1980 if (attHeading.startsWith("Characteristic")) { 1981 isValidCharacteristic = true; 1982 } 1983 1981 isValidCharacteristic = true; 1982 } 1983 1984 1984 if (buildSubProperty != null) { 1985 1985 if (attHeading.startsWith("Characteristic")) { … … 1998 1998 1999 1999 if (buildSubProperty != null && buildSubProperty.type != null) { 2000 createdProps.put(lastAttDbXref, buildSubProperty); 2000 createdProps.put(lastAttDbXref, buildSubProperty); 2001 2001 addToSubToTypes(subToTypes, currentSubId, buildSubProperty); 2002 2002 } 2003 2003 } 2004 2004 2005 2005 // Some submission mention e.g. an RNA Sample but the details of how that sample was created, 2006 2006 // stage, strain, etc are in a previous submission. There are references to previous submission … … 2013 2013 Map<String, SubmissionProperty> props, 2014 2014 Map<Integer, SubmissionReference> submissionRefs) { 2015 2015 2016 2016 for (Map.Entry<Integer, SubmissionReference> entry : submissionRefs.entrySet()) { 2017 2017 Integer submissionId = entry.getKey(); 2018 2018 SubmissionReference subRef = entry.getValue(); 2019 2020 2019 2020 2021 2021 List<AppliedData> refAppliedData = findAppliedDataFromReferencedSubmission(subRef); 2022 2022 for (AppliedData aData : refAppliedData) { … … 2029 2029 } 2030 2030 } 2031 2031 2032 2032 private List<AppliedData> findAppliedDataFromReferencedSubmission(SubmissionReference subRef) { 2033 2033 List<AppliedData> foundAppliedData = new ArrayList<AppliedData>(); … … 2035 2035 return foundAppliedData; 2036 2036 } 2037 2037 2038 2038 private List<AppliedProtocol> findAppliedProtocolsFromReferencedSubmission( 2039 2039 SubmissionReference subRef) { … … 2042 2042 return foundAppliedProtocols; 2043 2043 } 2044 2044 2045 2045 private void findAppliedProtocolsAndDataFromReferencedSubmission( 2046 2046 SubmissionReference subRef, … … 2055 2055 2056 2056 if (refDataValue.equals(currentDataValue) && refSubId.equals(currentDataSubId)) { 2057 LOG.info("REFSUBS found a matching data value: " + currentDataValue + " in sub " 2058 + dccIdMap.get(currentDataSubId) + " ref sub = " 2057 LOG.info("REFSUBS found a matching data value: " + currentDataValue + " in sub " 2058 + dccIdMap.get(currentDataSubId) + " ref sub = " 2059 2059 + dccIdMap.get(refSubId)); 2060 2060 2061 2061 Integer foundDataId = aData.dataId; 2062 2062 … … 2066 2066 } 2067 2067 } 2068 2069 2070 private List<Item> createFromWikiPage(String dccId, String clsName, 2071 Map<String, List<SubmissionProperty>> typeToProp, List<String> types) 2068 2069 2070 private List<Item> createFromWikiPage(String dccId, String clsName, 2071 Map<String, List<SubmissionProperty>> typeToProp, List<String> types) 2072 2072 throws ObjectStoreException { 2073 2073 List<Item> items = new ArrayList<Item>(); … … 2084 2084 2085 2085 private void storeSubmissionCollection(Integer storedSubmissionId, String name, 2086 List<Item> items) 2086 List<Item> items) 2087 2087 throws ObjectStoreException { 2088 2088 if (!items.isEmpty()) { … … 2091 2091 } 2092 2092 } 2093 2093 2094 2094 private List<String> getIdentifiersFromItems(Collection<Item> items) { 2095 2095 List<String> ids = new ArrayList<String>(); … … 2099 2099 return ids; 2100 2100 } 2101 2102 private List<Item> createItemsForSubmissionProperties(String dccId, String clsName, 2101 2102 private List<Item> createItemsForSubmissionProperties(String dccId, String clsName, 2103 2103 List<SubmissionProperty> subProps) 2104 2104 throws ObjectStoreException { … … 2112 2112 return items; 2113 2113 } 2114 2115 2114 2115 2116 2116 2117 2117 private Item getItemForSubmissionProperty(String clsName, SubmissionProperty prop, String dccId) … … 2128 2128 } 2129 2129 if (checkOfficialName == null) { 2130 LOG.info("Official name - missing for property: " 2130 LOG.info("Official name - missing for property: " 2131 2131 + prop.type + ", " + prop.wikiPageUrl); 2132 2132 return null; 2133 2133 } else if (checkOfficialName.size() != 1) { 2134 LOG.info("Official name - multiple times for property: " 2135 + prop.type + ", " + prop.wikiPageUrl + ", " 2134 LOG.info("Official name - multiple times for property: " 2135 + prop.type + ", " + prop.wikiPageUrl + ", " 2136 2136 + checkOfficialName); 2137 2137 } … … 2141 2141 propItem.setAttribute("type", getPreferredSynonym(prop.type)); 2142 2142 propItem.setAttribute("wikiLink", WIKI_URL + prop.wikiPageUrl); 2143 if (clsName.equals("DevelopmentalStage")) { 2143 if (clsName.equals("DevelopmentalStage")) { 2144 2144 setAttributeOnProp(prop, propItem, "sex", "sex"); 2145 2145 2146 2146 List<String> devStageValues = prop.details.get("developmental stage"); 2147 2147 if (devStageValues != null) { 2148 2148 for (String devStageValue : devStageValues) { 2149 propItem.addToCollection("ontologyTerms", 2149 propItem.addToCollection("ontologyTerms", 2150 2150 getDevStageTerm(devStageValue)); 2151 2151 } 2152 2152 } else { 2153 LOG.error("METADATA FAIL: no 'developmental stage' values for wiki page: " 2153 LOG.error("METADATA FAIL: no 'developmental stage' values for wiki page: " 2154 2154 + prop.wikiPageUrl); 2155 2155 } … … 2165 2165 } else if (clsName.equals("CellLine")) { 2166 2166 setAttributeOnProp(prop, propItem, "sex", "sex"); 2167 setAttributeOnProp(prop, propItem, "short description", 2167 setAttributeOnProp(prop, propItem, "short description", 2168 2168 "description"); 2169 2169 setAttributeOnProp(prop, propItem, "species", "species"); … … 2178 2178 setAttributeOnProp(prop, propItem, "Description", "description"); 2179 2179 setAttributeOnProp(prop, propItem, "details", "description"); 2180 2180 2181 2181 setAttributeOnProp(prop, propItem, "aliases", "name"); 2182 2182 setAttributeOnProp(prop, propItem, "reference", "reference"); … … 2198 2198 throws ObjectStoreException { 2199 2199 String targetText = null; 2200 String[] possibleTypes = new String[] {"target id"}; 2200 String[] possibleTypes = new String[] {"target id"}; 2201 2201 2202 2202 for (String targetType : possibleTypes) { 2203 2203 if (prop.details.containsKey(targetType)) { 2204 2204 if (prop.details.get(targetType).size() != 1) { 2205 2206 // we used to complain if multiple values, now only 2205 2206 // we used to complain if multiple values, now only 2207 2207 // if they don't have the same value 2208 2208 checkIfSameValue(prop, source, targetType); … … 2232 2232 private void checkIfSameValue(SubmissionProperty prop, String source, 2233 2233 String targetType) throws RuntimeException { 2234 String value = prop.details.get(targetType).get(0); 2234 String value = prop.details.get(targetType).get(0); 2235 2235 for (int i = 1; i < prop.details.get(targetType).size(); i++) { 2236 2236 String newValue = prop.details.get(targetType).get(i); 2237 2237 if (!newValue.equals(value)) { 2238 throw new RuntimeException(source + " should only have one value for '" + targetType 2239 + "' field: " + prop.details.get(targetType)); 2240 } 2241 } 2242 } 2243 2244 2245 private void setAttributeOnProp(SubmissionProperty subProp, Item item, String metadataName, 2238 throw new RuntimeException(source + " should only have one value for '" + targetType 2239 + "' field: " + prop.details.get(targetType)); 2240 } 2241 } 2242 } 2243 2244 2245 private void setAttributeOnProp(SubmissionProperty subProp, Item item, String metadataName, 2246 2246 String attributeName) { 2247 2247 … … 2258 2258 } 2259 2259 } 2260 } else if (metadataName.equalsIgnoreCase("description") 2260 } else if (metadataName.equalsIgnoreCase("description") 2261 2261 || metadataName.equalsIgnoreCase("details")) { 2262 2262 // description is often split in more than 1 line … … 2267 2267 } 2268 2268 item.setAttribute(attributeName, all); 2269 2269 2270 2270 } else { 2271 2271 String value = subProp.details.get(metadataName).get(0); … … 2273 2273 } 2274 2274 } 2275 } 2276 2277 2275 } 2276 2277 2278 2278 private String getTargetGeneItemIdentfier(String geneTargetIdText, String dccId) 2279 2279 throws ObjectStoreException { 2280 2280 String taxonId = ""; 2281 2281 String originalId = null; 2282 2282 2283 2283 String flyPrefix = "fly_genes:"; 2284 2284 String wormPrefix = "worm_genes:"; 2285 2285 2286 2286 if (geneTargetIdText.startsWith(flyPrefix)) { 2287 2287 originalId = geneTargetIdText.substring(flyPrefix.length()); … … 2297 2297 taxonId = "" + or.getOrganismDataByFullName(organism).getTaxonId(); 2298 2298 originalId = geneTargetIdText; 2299 LOG.info("RESOLVER: found organism '" + organism + "', taxon " + taxonId 2299 LOG.info("RESOLVER: found organism '" + organism + "', taxon " + taxonId 2300 2300 + " for submission " + dccId); 2301 2301 } … … 2307 2307 resolver = wormResolverFactory.getIdResolver(); 2308 2308 } else { 2309 LOG.info("RESOLVER: unable to work out organism for target id text: " 2309 LOG.info("RESOLVER: unable to work out organism for target id text: " 2310 2310 + geneTargetIdText); 2311 2311 } … … 2337 2337 + " found ids: " + resolver.resolveId(taxonId, originalId) + "."); 2338 2338 } else { 2339 primaryIdentifier = 2339 primaryIdentifier = 2340 2340 resolver.resolveId(taxonId, originalId).iterator().next(); 2341 LOG.info("RESOLVER found gene " + primaryIdentifier 2341 LOG.info("RESOLVER found gene " + primaryIdentifier 2342 2342 + " for original id: " + originalId); 2343 2343 } 2344 2344 return primaryIdentifier; 2345 2345 } 2346 2346 2347 2347 2348 2348 private List<Item> lookForAttributesInOtherWikiPages(String clsName, 2349 Map<String, List<SubmissionProperty>> typeToProp, String[] lookFor) 2349 Map<String, List<SubmissionProperty>> typeToProp, String[] lookFor) 2350 2350 throws ObjectStoreException { 2351 2351 … … 2359 2359 2360 2360 if (typeToProp.containsKey(type)) { 2361 for (SubmissionProperty subProp : typeToProp.get(type)) { 2361 for (SubmissionProperty subProp : typeToProp.get(type)) { 2362 2362 if (subProp.details.containsKey(propName)) { 2363 2363 for (String value : subProp.details.get(propName)) { 2364 items.add(createNonWikiSubmissionPropertyItem(clsName, 2365 getPreferredSynonym(propName), 2364 items.add(createNonWikiSubmissionPropertyItem(clsName, 2365 getPreferredSynonym(propName), 2366 2366 correctAttrValue(value))); 2367 2367 } … … 2376 2376 // which probably won't be a wiki page 2377 2377 if (typeToProp.containsKey(typeProp)) { 2378 for (SubmissionProperty subProp : typeToProp.get(typeProp)) { 2378 for (SubmissionProperty subProp : typeToProp.get(typeProp)) { 2379 2379 2380 2380 String value = subProp.wikiPageUrl; 2381 2381 2382 2382 // This is an ugly special case to deal with 'exposure time/24 hours' 2383 2383 if (subProp.details.containsKey("Unit")) { … … 2385 2385 value = value + " " + unit + (unit.endsWith("s") ? "" : "s"); 2386 2386 } 2387 2388 items.add(createNonWikiSubmissionPropertyItem(clsName, subProp.type, 2387 2388 items.add(createNonWikiSubmissionPropertyItem(clsName, subProp.type, 2389 2389 correctAttrValue(value))); 2390 2390 } … … 2394 2394 return items; 2395 2395 } 2396 2396 2397 2397 private String correctAttrValue(String value) { 2398 2398 if (value == null) { … … 2400 2400 } 2401 2401 value = value.replace("–", "-"); 2402 return value; 2403 } 2404 2405 2406 private Item createNonWikiSubmissionPropertyItem(String clsName, String type, String name) 2402 return value; 2403 } 2404 2405 2406 private Item createNonWikiSubmissionPropertyItem(String clsName, String type, String name) 2407 2407 throws ObjectStoreException { 2408 2408 if (clsName.equals("DevelopmentalStage")) { 2409 2409 name = correctDevStageTerm(name); 2410 2410 } 2411 2411 2412 2412 Item item = nonWikiSubmissionProperties.get(name); 2413 if (item == null) { 2413 if (item == null) { 2414 2414 item = createSubmissionProperty(clsName, name); 2415 2415 item.setAttribute("type", getPreferredSynonym(type)); 2416 2416 2417 2417 if (clsName.equals("DevelopmentalStage")) { 2418 2418 String ontologyTermId = getDevStageTerm(name); … … 2425 2425 return item; 2426 2426 } 2427 2427 2428 2428 private Item createSubmissionProperty(String clsName, String name) { 2429 Item subProp = getChadoDBConverter().createItem(clsName); 2430 if (name != null) { 2429 Item subProp = getChadoDBConverter().createItem(clsName); 2430 if (name != null) { 2431 2431 subProp.setAttribute("name", name); 2432 2432 } 2433 2433 2434 2434 return subProp; 2435 2435 } 2436 2437 2436 2437 2438 2438 private String getCorrectedOfficialName(SubmissionProperty prop) { 2439 2439 String preferredType = getPreferredSynonym(prop.type); … … 2448 2448 for (String lookup : makeLookupList(prop.type)) { 2449 2449 if (prop.details.containsKey(lookup)) { 2450 name = prop.details.get(lookup).get(0); 2450 name = prop.details.get(lookup).get(0); 2451 2451 } 2452 2452 } … … 2454 2454 return correctOfficialName(name, preferredType); 2455 2455 } 2456 2456 2457 2457 /** 2458 2458 * Unify variations on similar official names. … … 2465 2465 return null; 2466 2466 } 2467 2467 2468 2468 if (type.equals("developmental stage")) { 2469 2469 name = name.replace("_", " "); … … 2490 2490 if (name.matches(".*L\\d")) { 2491 2491 name = name + " stage larvae"; 2492 } 2492 } 2493 2493 if (name.matches("WPP.*")) { 2494 2494 name = name.replaceFirst("WPP", "White prepupae (WPP)"); 2495 2495 } 2496 2496 } 2497 return name; 2498 } 2499 2497 return name; 2498 } 2499 2500 2500 2501 2501 2502 2502 private String getDevStageTerm(String value) throws ObjectStoreException { 2503 2503 value = correctDevStageTerm(value); 2504 2504 2505 2505 String identifier = devStageTerms.get(value); 2506 2506 if (identifier == null) { 2507 2507 Item term = getChadoDBConverter().createItem("OntologyTerm"); 2508 2508 term.setAttribute("name", value); 2509 getChadoDBConverter().store(term); 2509 getChadoDBConverter().store(term); 2510 2510 devStageTerms.put(value, term.getIdentifier()); 2511 2511 identifier = term.getIdentifier(); … … 2523 2523 } 2524 2524 2525 2525 2526 2526 private Integer getSubmissionIdFromDccId(String dccId) { 2527 2527 for (Map.Entry<Integer, String> entry : dccIdMap.entrySet()) { … … 2544 2544 2545 2545 String sraAcc = "SRA acc"; 2546 2546 2547 2547 String query = "SELECT d.data_id, d.heading as data_heading," 2548 2548 + " d.name as data_name, d.value as data_value," … … 2584 2584 } 2585 2585 2586 private class SubmissionProperty 2586 private class SubmissionProperty 2587 2587 { 2588 2588 protected String type; … … 2604 2604 if (values == null) { 2605 2605 values = new ArrayList<String>(); 2606 details.put(type, values); 2606 details.put(type, values); 2607 2607 } 2608 2608 values.add(value); … … 2614 2614 } 2615 2615 2616 2617 private class DatabaseRecordConfig 2616 2617 private class DatabaseRecordConfig 2618 2618 { 2619 2619 private Set<Pattern> patterns = new HashSet<Pattern>(); … … 2622 2622 private String dbURL; 2623 2623 } 2624 2624 2625 2625 private Set<DatabaseRecordConfig> initDatabaseRecordConfigs() { 2626 2626 Set<DatabaseRecordConfig> configs = new HashSet<DatabaseRecordConfig>(); … … 2645 2645 sra.dbName = "SRA"; 2646 2646 sra.dbDescrition = "Sequence Read Archive (NCBI)"; 2647 sra.dbURL = 2647 sra.dbURL = 2648 2648 "http://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?cmd=viewer&m=data&s=viewer&run="; 2649 2649 p = Pattern.compile("SRA.*", Pattern.CASE_INSENSITIVE); … … 2654 2654 } 2655 2655 2656 2656 2657 2657 /** 2658 2658 * Query to get data attributes … … 2709 2709 2710 2710 Set<DatabaseRecordConfig> configs = initDatabaseRecordConfigs(); 2711 2711 2712 2712 for (Integer submissionId : submissionDataMap.keySet()) { 2713 2713 List<String> submissionDbRecords = new ArrayList<String>(); … … 2726 2726 if (!submissionDbRecords.isEmpty()) { 2727 2727 ReferenceList col = new ReferenceList("databaseRecords", submissionDbRecords); 2728 getChadoDBConverter().store(col, 2728 getChadoDBConverter().store(col, 2729 2729 submissionMap.get(submissionId).interMineObjectId); 2730 2730 } … … 2734 2734 } 2735 2735 2736 2737 private List<String> createDatabaseRecords(String accession, DatabaseRecordConfig config) 2736 2737 private List<String> createDatabaseRecords(String accession, DatabaseRecordConfig config) 2738 2738 throws ObjectStoreException { 2739 2739 List<String> dbRecordIds = new ArrayList<String>(); 2740 2740 2741 2741 Set<String> cleanAccessions = new HashSet<String>(); 2742 2742 2743 2743 // NOTE - this is a special case to deal with a very strange SRA accession format in some 2744 2744 // Celniker submissions. The 'accession' is provided as e.g. 2745 2745 // SRR013492.225322.1;SRR013492.462158.1;... 2746 // We just want the unique SRR ids 2746 // We just want the unique SRR ids 2747 2747 if (config.dbName.equals("SRA") && (accession.indexOf(';') != -1 2748 2748 || accession.indexOf('.') != -1)) { … … 2757 2757 cleanAccessions.add(accession); 2758 2758 } 2759 2759 2760 2760 for (String cleanAccession : cleanAccessions) { 2761 2761 dbRecordIds.add(createDatabaseRecord(cleanAccession, config)); … … 2763 2763 return dbRecordIds; 2764 2764 } 2765 2766 2767 private String createDatabaseRecord(String accession, DatabaseRecordConfig config) 2765 2766 2767 private String createDatabaseRecord(String accession, DatabaseRecordConfig config) 2768 2768 throws ObjectStoreException { 2769 2769 DatabaseRecordKey key = new DatabaseRecordKey(config.dbName, accession); … … 2773 2773 dbRecord.setAttribute("database", config.dbName); 2774 2774 dbRecord.setAttribute("description", config.dbDescrition); 2775 if (StringUtil .isEmpty(accession)) {2775 if (StringUtils.isEmpty(accession)) { 2776 2776 dbRecord.setAttribute("accession", "To be confirmed"); 2777 2777 } else { … … 2786 2786 return dbRecordId; 2787 2787 } 2788 2789 2790 private class DatabaseRecordKey 2788 2789 2790 private class DatabaseRecordKey 2791 2791 { 2792 2792 private String db; 2793 2793 private String accession; 2794 2794 2795 2795 /** 2796 2796 * Construct with the database and accession … … 2802 2802 this.accession = accession; 2803 2803 } 2804 2804 2805 2805 /** 2806 2806 * {@inheritDoc} … … 2809 2809 if (o instanceof DatabaseRecordKey) { 2810 2810 DatabaseRecordKey otherKey = (DatabaseRecordKey) o; 2811 if (!StringUtil.isEmpty(accession) && !StringUtil.isEmpty(otherKey.accession)) { 2812 return this.db.equals(otherKey.db) && this.accession.equals(otherKey.accession); 2811 if (StringUtils.isNotEmpty(accession) 2812 && StringUtils.isNotEmpty(otherKey.accession)) { 2813 return this.db.equals(otherKey.db) 2814 && this.accession.equals(otherKey.accession); 2813 2815 } 2814 2816 } 2815 2817 return false; 2816 2818 } 2817 2819 2818 2820 /** 2819 2821 * {@inheritDoc} … … 2823 2825 } 2824 2826 } 2825 2827 2826 2828 //sub -> prot 2827 2829 private void setSubmissionProtocolsRefs(Connection connection) … … 2841 2843 Integer thisSubmissionId = subs.next(); 2842 2844 List<Integer> protocolChadoIds = submissionProtocolMap.get(thisSubmissionId); 2843 2845 2844 2846 ReferenceList collection = new ReferenceList(); 2845 2847 collection.setName("protocols"); … … 2849 2851 Integer storedSubmissionId = submissionMap.get(thisSubmissionId).interMineObjectId; 2850 2852 getChadoDBConverter().store(collection, storedSubmissionId); 2851 2853 2852 2854 // may need protocols from referenced submissions to work out experiment type 2853 2855 protocolChadoIds.addAll(findProtocolIdsFromReferencedSubmissions(thisSubmissionId)); 2854 2856 2855 2857 String piName = submissionProjectMap.get(thisSubmissionId); 2856 2858 setSubmissionExperimentType(storedSubmissionId, protocolChadoIds, piName); … … 2874 2876 } 2875 2877 } 2876 2878 2877 2879 // Fetch protocols used to create reagents that are inputs to this submission, these are 2878 2880 // found in referenced submissions 2879 2881 private List<Integer> findProtocolIdsFromReferencedSubmissions(Integer submissionId) { 2880 2882 List<Integer> protocolIds = new ArrayList<Integer>(); 2881 2883 2882 2884 if (submissionRefs == null) { 2883 2885 throw new RuntimeException("Attempting to access submissionRefs before it has been" … … 2885 2887 + " processSubmissionProperties"); 2886 2888 } 2887 2889 2888 2890 SubmissionReference subRef = submissionRefs.get(submissionId); 2889 2891 if (subRef != null) { … … 2892 2894 } 2893 2895 } 2894 2896 2895 2897 return protocolIds; 2896 2898 } 2897 2898 /** 2899 2900 /** 2899 2901 * Work out an experiment type give the combination of protocols used for the 2900 2902 * submussion. e.g. *immunoprecipitation + hybridization = chIP-chip 2901 2903 * @param protocolTypes the protocal types 2904 * @param piName name of PI 2902 2905 * @return a short experiment type 2903 2906 */ … … 2915 2918 } 2916 2919 } 2917 2920 2918 2921 // reverse transcription + PCR + RACE = RACE 2919 2922 // reverse transcription + PCR - RACE = RTPCR … … 2926 2929 } 2927 2930 } 2928 2931 2929 2932 // ChIP + hybridization = ChIP-chip 2930 2933 // ChIP - hybridization = ChIP-seq … … 2934 2937 } else { 2935 2938 return "ChIP-seq"; 2936 } 2937 } 2938 2939 } 2940 } 2941 2939 2942 // hybridization - ChIP = 2940 2943 // Celniker: RNA tiling array … … 2952 2955 2953 2956 } 2954 2957 2955 2958 // annotation = Computational annotation 2956 2959 if (containsMatch(protocolTypes, "annotation")) { 2957 2960 return "Computational annotation"; 2958 2961 } 2959 2962 2960 2963 // If we haven't found a type yet, and there is a growth protocol, then 2961 2964 // this is probably an RNA sample creation experiment from Celniker … … 2963 2966 return "RNA sample creation"; 2964 2967 } 2965 2968 2966 2969 return null; 2967 2970 } 2968 2971 2969 2972 // utility method for looking up in a set by regular expression 2970 2973 private boolean containsMatch(Set<String> testSet, String regex) { … … 2979 2982 return matches; 2980 2983 } 2981 2984 2982 2985 //sub -> exp 2983 2986 private void setSubmissionExperimetRefs(Connection connection) … … 3030 3033 } 3031 3034 } 3032 LOG.info("TIME setting submission-exFactors references: " 3035 LOG.info("TIME setting submission-exFactors references: " 3033 3036 + (System.currentTimeMillis() - bT)); 3034 3037 } … … 3050 3053 submissionMap.get(thisSubmissionId).interMineObjectId); 3051 3054 } 3052 LOG.info("TIME setting submission-publication references: " 3055 LOG.info("TIME setting submission-publication references: " 3053 3056 + (System.currentTimeMillis() - bT)); 3054 3057 } 3055 3058 3056 3057 3058 3059 3060 3061 3059 3062 3060 3063 /** … … 3088 3091 } 3089 3092 } 3090 LOG.info("TIME setting DAG references: " + (System.currentTimeMillis() - bT)); 3093 LOG.info("TIME setting DAG references: " + (System.currentTimeMillis() - bT)); 3091 3094 } 3092 3095 … … 3193 3196 dataSubmissionMap.put(dataId, submissionId); 3194 3197 } 3195 3198 3196 3199 /** 3197 3200 * ===================== … … 3199 3202 * ===================== 3200 3203 */ 3201 3204 3202 3205 /** 3203 3206 * method to wrap the execution of a query, without log info … … 3233 3236 } 3234 3237 3235 3238 3236 3239 /** 3237 3240 * adds an element to a list which is the value of a map … … 3271 3274 } 3272 3275 } 3273 3274 3276 3277 3275 3278 /** 3276 3279 * adds an element to a list which is the value of a map -
trunk/bio/sources/chado-db/main/src/org/intermine/bio/dataconversion/WormBaseProcessor.java
r20655 r20738 17 17 import org.apache.commons.collections.keyvalue.MultiKey; 18 18 import org.apache.commons.collections.map.MultiKeyMap; 19 import org.apache.commons.lang.StringUtils; 19 20 import org.apache.log4j.Logger; 20 21 import org.intermine.bio.chado.config.ConfigAction; 21 22 import org.intermine.bio.chado.config.SetFieldConfigAction; 22 23 import org.intermine.objectstore.ObjectStoreException; 23 import org.intermine.util.StringUtil;24 24 import org.intermine.xml.full.Item; 25 25 … … 50 50 return itemId; 51 51 } 52 52 53 53 /** 54 54 * Method to add dataSets and DataSources to items before storing … … 78 78 converter.getDataSourceItem().getIdentifier()); 79 79 } 80 81 80 82 81 /** 83 82 * {@inheritDoc} … … 132 131 @Override 133 132 protected String fixIdentifier(FeatureData fdat, String identifier) { 134 133 135 134 String uniqueName = fdat.getChadoFeatureUniqueName(); 136 135 String type = fdat.getInterMineType(); 137 136 138 // the function is used without check for null only for uniquename and name 137 // the function is used without check for null only for uniquename and name 139 138 // in SequenceProcessor. 140 139 // so we assume that uniquename is never null and that if null it is a name. 141 if (StringUtil .isEmpty(identifier)) {140 if (StringUtils.isEmpty(identifier)) { 142 141 identifier = uniqueName; 143 142 LOG.debug("Found NULL name for feature: " + uniqueName); 144 } 145 143 } 144 146 145 if (identifier.startsWith(type + ":")) { 147 146 return identifier.substring(type.length() + 1); 148 } else {149 return identifier;150 147 } 148 return identifier; 151 149 } 152 150 153 151 /** 154 152 * Wormbase chado has pmid prefixed to pubmed identifiers 155 * @param string pubmedid fetched from databaase153 * @param pubmedStr id fetched from databaase 156 154 * @return the pubmed id 157 155 */ -
trunk/bio/sources/flymine/flyatlas/main/src/org/intermine/bio/dataconversion/FlyAtlasConverter.java
r20462 r20738 22 22 import org.intermine.objectstore.ObjectStoreException; 23 23 import org.intermine.util.FormattedTextParser; 24 import org.intermine.util.StringUtil;25 24 import org.intermine.xml.full.Item; 26 25 … … 67 66 String probeId = line[0]; 68 67 // there seems to be some empty lines at the end of the file 69 if (StringUtil .isEmpty(probeId)) {68 if (StringUtils.isEmpty(probeId)) { 70 69 break; 71 70 } -
trunk/intermine/integrate/main/src/org/intermine/xml/full/Item.java
r20462 r20738 19 19 import java.util.Set; 20 20 21 import org.apache.commons.lang.StringUtils; 21 22 import org.intermine.metadata.ClassDescriptor; 22 23 import org.intermine.metadata.Model; … … 414 415 */ 415 416 public void addToCollection(String name, String refId) { 416 if (StringUtil .isEmpty(refId)) {417 if (StringUtils.isEmpty(refId)) { 417 418 throw new RuntimeException("empty string added to collection for: " + name); 418 419 } … … 613 614 614 615 for (String clsName : bits) { 615 if (!StringUtil .isEmpty(clsName)) {616 if (!StringUtils.isEmpty(clsName)) { 616 617 implementationClassDescriptors.add(getClassDescriptorByName(clsName)); 617 618 } -
trunk/intermine/objectstore/main/src/org/intermine/util/StringUtil.java
r20669 r20738 462 462 } 463 463 return "a"; 464 }465 466 467 /**468 * Returns true if the given String is null or the empty String.469 *470 * @param str checked string471 * @return true if string is null or empty472 */473 public static boolean isEmpty(String str) {474 if (str == null) {475 return true;476 }477 return str.length() == 0;478 464 } 479 465 -
trunk/intermine/pathquery/main/src/org/intermine/pathquery/PathQuery.java
r20593 r20738 27 27 import java.util.regex.Pattern; 28 28 29 import org.apache.commons.lang.StringUtils; 29 30 import org.apache.log4j.Logger; 30 31 import org.intermine.metadata.ClassDescriptor; … … 35 36 import org.intermine.objectstore.query.ConstraintOp; 36 37 import org.intermine.util.CollectionUtil; 37 import org.intermine.util.StringUtil;38 38 39 39 /** … … 820 820 } 821 821 for (Iterator<String> iter = codes.iterator(); iter.hasNext(); ) { 822 if ( !StringUtil.isEmpty(logic)) {822 if (StringUtils.isNotEmpty(logic)) { 823 823 logic += " " + operator + " "; 824 824 } -
trunk/intermine/web/main/src/org/intermine/web/logic/session/SessionMethods.java
r20593 r20738 446 446 447 447 /** 448 * Get the COLLAPSED map from the session. If the attribute is not present then a new449 * map will be created.450 *451 * @param session the curren session452 * @return the COLLAPSED map attribute453 */454 public static Map getCollapsedMap(HttpSession session) {455 Map collapsed = (Map) session.getAttribute(Constants.COLLAPSED);456 if (collapsed == null) {457 collapsed = new HashMap();458 session.setAttribute(Constants.COLLAPSED, collapsed);459 }460 return collapsed;461 }462 463 /**464 448 * Return the displayObjects Map from the session or create and return it if it doesn't exist. 465 449 * -
trunk/intermine/web/main/src/org/intermine/web/struts/HtmlHeadController.java
r20462 r20738 15 15 import javax.servlet.http.HttpSession; 16 16 17 import org.apache.commons.lang.StringUtils; 17 18 import org.apache.log4j.Logger; 18 19 import org.apache.struts.action.ActionForm; … … 29 30 import org.intermine.objectstore.ObjectStore; 30 31 import org.intermine.util.DynamicUtil; 31 import org.intermine.util.StringUtil;32 32 import org.intermine.web.logic.results.DisplayObject; 33 33 import org.intermine.web.logic.results.DisplayObjectFactory; … … 54 54 * @exception Exception if an error occurs 55 55 */ 56 public ActionForward execute( @SuppressWarnings("unused")ComponentContext context,57 @SuppressWarnings("unused")ActionMapping mapping,58 @SuppressWarnings("unused")ActionForm form,56 public ActionForward execute(ComponentContext context, 57 ActionMapping mapping, 58 ActionForm form, 59 59 HttpServletRequest request, 60 @SuppressWarnings("unused")HttpServletResponse response)60 HttpServletResponse response) 61 61 throws Exception { 62 62 … … 116 116 return null; 117 117 } 118 DisplayObject dobj = (DisplayObject)displayObjects.get(object);118 DisplayObject dobj = displayObjects.get(object); 119 119 120 120 String className = DynamicUtil.getFriendlyName(dobj.getObject().getClass()); … … 133 133 134 134 // TODO use the class keys instead of hardcoding which fields should be used 135 if (StringUtil .isEmpty(idForPageTitle)135 if (StringUtils.isEmpty(idForPageTitle) 136 136 && dobj.getAttributes().get("secondaryIdentifier") != null) { 137 137 idForPageTitle = dobj.getAttributes().get("secondaryIdentifier").toString(); 138 138 } 139 if (StringUtil .isEmpty(idForPageTitle)139 if (StringUtils.isEmpty(idForPageTitle) 140 140 && dobj.getAttributes().get("identifier") != null) { 141 141 idForPageTitle = dobj.getAttributes().get("identifier").toString(); 142 142 } 143 if (StringUtil .isEmpty(idForPageTitle)143 if (StringUtils.isEmpty(idForPageTitle) 144 144 && dobj.getAttributes().get("symbol") != null) { 145 145 idForPageTitle = dobj.getAttributes().get("symbol").toString(); 146 146 } 147 147 148 if ( !StringUtil.isEmpty(idForPageTitle)) {148 if (StringUtils.isNotEmpty(idForPageTitle)) { 149 149 htmlPageTitle = className + " report for " + idForPageTitle; 150 150 }
Note: See TracChangeset
for help on using the changeset viewer.
