diff --git a/README.md b/README.md index 9b842cad..3bf035d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # The BioPAX Validator -(code and docs permanently moved from Sourceforge, hg.code.sf.net/p/biopax/validator, to here on GitHub) +(code and docs permanently moved from Sourceforge, hg.code.sf.net/p/biopax/validator, to GitHub) BioPAX.org [online BioPAX Validator](http://www.biopax.org/validator/) diff --git a/biopax-validator/src/main/java/org/biopax/validator/rules/PathwayMultiOrganismRule.java b/biopax-validator/src/main/java/org/biopax/validator/rules/PathwayMultiOrganismRule.java index b6aaf725..5d1c9456 100644 --- a/biopax-validator/src/main/java/org/biopax/validator/rules/PathwayMultiOrganismRule.java +++ b/biopax-validator/src/main/java/org/biopax/validator/rules/PathwayMultiOrganismRule.java @@ -1,77 +1,54 @@ package org.biopax.validator.rules; -/* - * - */ - -import java.util.Collection; -import java.util.HashSet; - -import org.biopax.paxtools.controller.AbstractTraverser; +import org.biopax.paxtools.controller.Fetcher; +import org.biopax.paxtools.controller.PathAccessor; import org.biopax.paxtools.controller.PropertyEditor; -import org.biopax.paxtools.util.Filter; -import org.biopax.paxtools.model.BioPAXElement; -import org.biopax.paxtools.model.Model; +import org.biopax.paxtools.controller.SimpleEditorMap; import org.biopax.paxtools.model.level3.BioSource; import org.biopax.paxtools.model.level3.Pathway; +import org.biopax.paxtools.util.Filter; import org.biopax.validator.api.AbstractRule; import org.biopax.validator.api.beans.Validation; -import org.biopax.paxtools.controller.SimpleEditorMap; import org.springframework.stereotype.Component; +import java.util.HashSet; +import java.util.Set; + /** * Warn if a pathway and its component have different (not null) 'organism' values. * What to do? (ignore, delete this value, or override nested organism properties with pathway's value) - * + * * @author rodche */ @Component -public class PathwayMultiOrganismRule extends AbstractRule -{ - private final static Filter filter = new Filter() { +public class PathwayMultiOrganismRule extends AbstractRule { + private final static Filter filter = new Filter() { - public boolean filter(PropertyEditor editor) { - return !"nextStep".equals(editor.getProperty()); - } - }; - - public void check(final Validation validation, final Pathway pathway) { - final Collection organisms = new HashSet(); - final BioSource organism = pathway.getOrganism(); // not null - due to the canCheck method! - //but.. - if(organism==null) return; // we do not care - - AbstractTraverser runner = new AbstractTraverser( - SimpleEditorMap.L3, filter) - { - @Override - protected void visit(Object value, BioPAXElement parent, - Model model, PropertyEditor editor) - { - if(value instanceof BioSource) { - if(!((BioPAXElement) value).isEquivalent(organism)) { - organisms.add((BioPAXElement) value); - } - } - else if (value instanceof BioPAXElement) { - logger.trace("Traverse into " + value + " " - + value.getClass().getSimpleName()); - traverse((BioPAXElement) value, model); - } - } - }; - - runner.traverse(pathway, null); - - if(organisms.size()>0) { - error(validation, pathway, "multi.organism.pathway", - false, organism, organisms); - } + public boolean filter(PropertyEditor editor) { + //skip for: nextStep (those can be reached via pathwayOrder or pathwayComponent) and evidence (multi-org. is normal there) + return !("nextStep".equals(editor.getProperty()) || "evidence".equals(editor.getProperty())); } + }; + + public void check(final Validation validation, final Pathway pathway) { + Fetcher fetcher = new Fetcher(SimpleEditorMap.L3, Fetcher.evidenceFilter, Fetcher.nextStepFilter); + fetcher.setSkipSubPathways(true); + final Set organisms = fetcher.fetch(pathway, BioSource.class); + //collect taxonomy IDs (from the BioSource objects that have valid xrefs) + PathAccessor accessor = new PathAccessor("BioSource/xref:UnificationXref/id"); + Set taxIds = accessor.getValueFromBeans(organisms); + if (taxIds.size() > 1) { + accessor = new PathAccessor("BioSource/name"); + Set names = new HashSet(); + for(Object name : accessor.getValueFromBeans(organisms)) + names.add(String.valueOf(name).toLowerCase()); - public boolean canCheck(Object thing) { - return thing instanceof Pathway - && ((Pathway)thing).getOrganism() != null; + error(validation, pathway, "multi.organism.pathway", false, taxIds, names); } + } + + public boolean canCheck(Object thing) { + return thing instanceof Pathway; + } } diff --git a/biopax-validator/src/main/resources/codes.properties b/biopax-validator/src/main/resources/codes.properties index 001be62b..08b3e78d 100644 --- a/biopax-validator/src/main/resources/codes.properties +++ b/biopax-validator/src/main/resources/codes.properties @@ -167,8 +167,8 @@ direction.conflict.default=An illegal value or a conflict between related "direc direction.conflict={0} direction.conflict.category=recommendation -multi.organism.pathway.default=Components have different values for the 'organism' property. Check that this is a valid multi-organism interaction -multi.organism.pathway=pathway has: {0}, components have: {1} +multi.organism.pathway.default=Different organism references are found in a pathway and/or its members (excl. evidence). Is this indeed a multi-organism pathway? +multi.organism.pathway=BioSources (unification xref IDs): {0} (names: {1}) multi.organism.pathway.category=recommendation complex.incomplete.default=Complex has no components, or the one without properly defined stoichiometry diff --git a/distr/src/main/etc/README.txt b/distr/src/main/etc/README.txt index b1010c47..71960050 100644 --- a/distr/src/main/etc/README.txt +++ b/distr/src/main/etc/README.txt @@ -28,32 +28,13 @@ http://www.biopax.org/validator http://sourceforge.net/projects/biopax/ -## -# Copyright (C) 2008 - 2013 University of Toronto (baderlab.org) and Memorial Sloan-Kettering Cancer Center (cbio.mskcc.org) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Lesser Public License for more details. -# -# You should have received a copy of the GNU General Lesser Public -# License along with this program. If not, see -# . -## - - ****************************************************************************** INSTALLATION ****************************************************************************** Download the latest ZIP distribution from -http://sourceforge.net/projects/biopax/files/validator/ +http://www.biopax.org/downloads/validator/ Unpack and use (it also includes the WAR file).