Permalink
Browse files

Changes to make the BII handle external URIs better. Requires further…

… testing by @proccaserra #49
  • Loading branch information...
eamonnmag committed Feb 19, 2012
1 parent d7ebd94 commit 4955750e703f16e646e7539ee97f32421754e6e7
@@ -47,10 +47,8 @@
import org.apache.lucene.document.Field;
import org.hibernate.search.bridge.FieldBridge;
import org.hibernate.search.bridge.LuceneOptions;
-import uk.ac.ebi.bioinvindex.model.Annotation;
import uk.ac.ebi.bioinvindex.model.AssayResult;
import uk.ac.ebi.bioinvindex.model.processing.Assay;
-import uk.ac.ebi.bioinvindex.model.term.AnnotationTypes;
import uk.ac.ebi.bioinvindex.model.xref.Xref;
import uk.ac.ebi.bioinvindex.search.hibernatesearch.StudyBrowseField;
import uk.ac.ebi.bioinvindex.utils.datasourceload.DataLocationManager;
@@ -81,31 +79,7 @@ public void set(String s, Object o, Document document, LuceneOptions luceneOptio
dataLocationManager.setEntityManager(entityManager);
for (Assay assay : assays) {
-
- if (assay.getTechnologyName().equals("mass spectrometry")) {
- Collection<AssayResult> assayResults = ProcessingUtils.findAssayResultsFromAssay(assay);
-
- String fileLink = dataLocationManager.getDataLocationLink(assay.getMeasurement().getName(), assay.getTechnologyName(), assay.getStudy().getObfuscationCode(),
- AnnotationTypes.GENERIC_DATA_FILE_LINK);
-
- System.out.println("File link: " + fileLink);
-
- String pathLink = dataLocationManager.getDataLocationLink(assay.getMeasurement().getName(), assay.getTechnologyName(), assay.getStudy().getObfuscationCode(),
- AnnotationTypes.GENERIC_DATA_FILE_PATH);
-
- System.out.println("Path link: " + pathLink);
-
- for (AssayResult result : assayResults) {
- for (Annotation annotation : result.getData().getAnnotation("metaboliteFile")) {
- System.out.printf("Type: %s -> Value: %s\n", annotation.getType().getValue(), annotation.getText());
-
- MetaboLightsIndexer.indexMetaboliteFile(pathLink.replace("${study-acc}",
- assay.getStudy().getObfuscationCode()) + annotation.getText(),
- document,
- luceneOptions);
- }
- }
- }
+ Collection<AssayResult> assayResults = ProcessingUtils.findAssayResultsFromAssay(assay);
String type = buildType(assay);
@@ -114,19 +88,11 @@ public void set(String s, Object o, Document document, LuceneOptions luceneOptio
assayTypeToInfo.put(type, info);
}
- for (Xref xref : assay.getXrefs()) {
- System.out.println("Adding XREF to AssayTypeInfo: " + xref.getSource().getAcc() + "(" + xref.getAcc() + ") for " + type);
-
- StringBuilder sb = new StringBuilder();
- sb.append("xref(").append(xref.getAcc()).append("->");
- sb.append(xref.getSource().getAcc()).append(")");
-
- assayTypeToInfo.get(type).addAccession(sb.toString());
- }
+ createAssayExternalLinks(assayTypeToInfo, assayResults, type);
+ createXrefs(assayTypeToInfo, assay, type);
assayTypeToInfo.get(type).increaseCount();
}
- // each data link should be stored perhaps, or at least whatever is required to make it display in the Study page.
for (String type : assayTypeToInfo.keySet()) {
StringBuilder fullInfo = new StringBuilder();
@@ -160,6 +126,35 @@ public void set(String s, Object o, Document document, LuceneOptions luceneOptio
entityManager.close();
}
+ private void createXrefs(Map<String, AssayTypeInfo> assayTypeToInfo, Assay assay, String type) {
+ for (Xref xref : assay.getXrefs()) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("xref(").append(xref.getAcc()).append("->");
+ sb.append(xref.getSource().getAcc()).append(")");
+ assayTypeToInfo.get(type).addAccession(sb.toString());
+ }
+ }
+
+ private void createAssayExternalLinks(Map<String, AssayTypeInfo> assayTypeToInfo, Collection<AssayResult> assayResults, String type) {
+ Set<String> addedLinks = new HashSet<String>();
+ for (AssayResult result : assayResults) {
+ // we're only looking at links...should accommodate webdav etc. too
+ //todo remove this after testing
+ if (!result.getData().getName().matches("(http|ftp|https).*") && result.getData().getName().contains("/")) {
+ // we only store the folder since that will take us to multiple file locations. Otherwise we'd have too
+ // many individual links pointing to the same place.
+ String folder = result.getData().getName().substring(0, result.getData().getName().lastIndexOf("/"));
+ if (!addedLinks.contains(folder)) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("link(").append(folder).append("->");
+ sb.append(result.getData().getType().getName()).append(")");
+ addedLinks.add(folder);
+ assayTypeToInfo.get(type).addAccession(sb.toString());
+ }
+ }
+ }
+ }
+
private String buildType(Assay assay) {
return assay.getMeasurement().getName() + "|" + assay.getTechnologyName();
}
@@ -11,7 +11,8 @@
public enum Repository {
PRIDE("^[0-9]+","pride"), ARRAYEXPRESS("^(e-).*", "arrayexpress"), GEO("^[(gse)|(ges)]*[0-9]+", "geo"),
- ENA("^[(sra)|(ena)]*[0-9]+","embl-bank", "ena", "ebi/ena"), GENERIC("generic", "generic", "none", "generic proteomic location", "generic microarray location");
+ ENA("^[(sra)|(ena)]*[0-9]+","embl-bank", "ena", "ebi/ena"),
+ GENERIC("generic", "generic", "none", "generic proteomic location", "generic microarray location");
private String startString;
@@ -65,6 +65,8 @@
@AutoCreate
public class SourceURLResolverImpl implements SourceURLResolver {
+ public static final String EXTERNAL_LINK_PATTERN = "(http|ftp|https).*";
+
private static Cache<String, String> cache = new BIICache<String, String>();
private static final Log log = LogFactory.getLog(SourceURLResolverImpl.class);
@@ -74,16 +76,21 @@
public String getRawDataURL(String measurement, String technology, String accession) {
try {
+ if (checkIsExternalLink(accession)) return accession;
return getDataURL(measurement, technology, accession, AnnotationTypes.RAW_DATA_FILE_LINK);
} catch (Exception e) {
log.error("Unable to resolve Raw data URL");
return "";
}
}
+ private boolean checkIsExternalLink(String accession) {
+ return accession.matches(EXTERNAL_LINK_PATTERN);
+ }
+
public String getProcessedDataURL(String measurement, String technology, String accession) {
try {
-
+ if (checkIsExternalLink(accession)) return accession;
return getDataURL(measurement, technology, accession, AnnotationTypes.PROCESSED_DATA_FILE_LINK);
} catch (Exception e) {
log.error("Unable to resolve Processed data URL");
@@ -94,23 +94,11 @@
@In(required = false)
private StudyIndexLocatorImpl studyIndexLocator;
-
- private String organism;
-
- private String design;
-
- private Map<String, List<String>> factorsToValues;
-
- private Map<String, List<String>> characteristicsToValues;
-
- private List<Contact> contacts;
-
- private List<AssayGroupInfo> assayInfos;
-
- private String studyId;
-
+ private String studyId, organism, design;
private Collection<Investigation> investigations;
-
+ private List<AssayGroupInfo> assayInfos;
+ private List<Contact> contacts;
+ private Map<String, List<String>> characteristicsToValues, factorsToValues;
private List<String> relatedStudies;
public StudyBeanImpl() {
@@ -354,12 +354,12 @@ private AssayInfoBean createAssayInfoBean(AssayInfoBean assayInfoBean, String as
private DataLink createDBLink(String dbLinkRepresentation) {
DataLink link = new DataLink();
- dbLinkRepresentation = dbLinkRepresentation.replace("xref(", "").replace(")", "");
+ dbLinkRepresentation = dbLinkRepresentation.replace("xref(", "").replace("link(", "").replace(")", "");
if (dbLinkRepresentation.contains("->")) {
String[] dbLinkParts = dbLinkRepresentation.split("->");
link.setAcc(dbLinkParts[0]);
- link.setSourceName(dbLinkParts[1]);
+ link.setSourceName(dbLinkParts[1].toUpperCase());
}
return link;
@@ -1,172 +0,0 @@
-package uk.ac.ebi.bioinvindex.services.compound;
-
-/*
- * __________
- * CREDITS
- * __________
- *
- * Team page: http://isatab.sf.net/
- * - Marco Brandizi (software engineer: ISAvalidator, ISAconverter, BII data management utility, BII model)
- * - Eamonn Maguire (software engineer: ISAcreator, ISAcreator configurator, ISAvalidator, ISAconverter, BII data management utility, BII web)
- * - Nataliya Sklyar (software engineer: BII web application, BII model, BII data management utility)
- * - Philippe Rocca-Serra (technical coordinator: user requirements and standards compliance for ISA software, ISA-tab format specification, BII model, ISAcreator wizard, ontology)
- * - Susanna-Assunta Sansone (coordinator: ISA infrastructure design, standards compliance, ISA-tab format specification, BII model, funds raising)
- *
- * Contributors:
- * - Manon Delahaye (ISA team trainee: BII web services)
- * - Richard Evans (ISA team trainee: rISAtab)
- *
- *
- * ______________________
- * Contacts and Feedback:
- * ______________________
- *
- * Project overview: http://isatab.sourceforge.net/
- *
- * To follow general discussion: isatab-devel@list.sourceforge.net
- * To contact the developers: isatools@googlegroups.com
- *
- * To report bugs: http://sourceforge.net/tracker/?group_id=215183&atid=1032649
- * To request enhancements: http://sourceforge.net/tracker/?group_id=215183&atid=1032652
- *
- *
- * __________
- * License:
- * __________
- *
- * This work is licenced under the Creative Commons Attribution-Share Alike 2.0 UK: England & Wales License. To view a copy of this licence, visit http://creativecommons.org/licenses/by-sa/2.0/uk/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
- *
- * __________
- * Sponsors
- * __________
- * This work has been funded mainly by the EU Carcinogenomics (http://www.carcinogenomics.eu) [PL 037712] and in part by the
- * EU NuGO [NoE 503630](http://www.nugo.org/everyone) projects and in part by EMBL-EBI.
- */
-
-import org.jboss.seam.util.Base64;
-
-import javax.imageio.ImageIO;
-import java.util.ArrayList;
-import java.util.List;
-import java.awt.image.RenderedImage;
-import java.awt.image.BufferedImage;
-import java.awt.*;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.Serializable;
-
-
-/**
- * Object to represent results of ChEBI query for use when creating compound page....
- * @author: eamonnmaguire
- * @date Oct 15, 2008
- */
-public class ChEBICompound implements Comparable {
- private static final String CHEBI_URL = "http://www.ebi.ac.uk/chebi/searchId.do?chebiId=";
- private String chebiId;
- private String name;
- private String definitions;
- private String structure;
- private String formula;
- private String imgLoc;
-
- // we also need information about the related studies!
- private List<String> studyAcc;
- private List<String> organsUsedOn;
- private List<String> organismsUsedOn;
-
- /**
- * ChEBICompound constructor
- * @param chebiId - ChEBI ID for the compound
- * @param name - Name of compound
- * @param definitions - Definition of the compound
- * @param structure - A String containing a MDL MolFile representation of the Compound structure for later rendering
- * @param formula - The formula representing the compound
- */
- public ChEBICompound(String chebiId, String name, String definitions,
- String structure, String formula, String imgLoc) {
- this.chebiId = chebiId;
- this.name = name;
- this.definitions = definitions;
- this.structure = structure;
- this.formula = formula;
- this.imgLoc = imgLoc;
-
- organismsUsedOn = new ArrayList<String>();
- organsUsedOn = new ArrayList<String>();
- studyAcc = new ArrayList<String>();
- }
-
- public void addToOrganismsUsed(String organismUsedOn) {
-
- if (!this.organismsUsedOn.contains(organismUsedOn)) {
- this.organismsUsedOn.add(organismUsedOn);
- }
- }
-
- public void addToOrgansUsed(String organUsedOn) {
-
- if (!this.organsUsedOn.contains(organUsedOn)) {
- this.organsUsedOn.add(organUsedOn);
- }
- }
-
- public int compareTo(Object cc) {
- int result = ((ChEBICompound) cc).getName().toLowerCase()
- .compareTo(name.toLowerCase());
-
- if (result < 0) {
- return 1;
- } else if (result > 0) {
- return -1;
- }
-
- return 0;
- }
-
- public String getChebiId() {
- return chebiId;
- }
-
- public static String getChebiUrl() {
- return CHEBI_URL;
- }
-
- public String getDefinitions() {
- return definitions;
- }
-
- public String getFormula() {
- return formula;
- }
-
- public String getName() {
- return name;
- }
-
- public List<String> getOrganismsUsedOn() {
- return organismsUsedOn;
- }
-
- public List<String> getOrgansUsedOn() {
- return organsUsedOn;
- }
-
- public String getStructure() {
- return structure;
- }
-
- public List<String> getStudyAcc() {
- return studyAcc;
- }
-
- public String getImgLoc() {
- return imgLoc;
- }
-
-
-
- public void setStudyAcc(List<String> studyAcc) {
- this.studyAcc = studyAcc;
- }
-}
Oops, something went wrong.

0 comments on commit 4955750

Please sign in to comment.