Skip to content

Commit

Permalink
Removed experimental L2-specific command 'integrate', some todos, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorRodchenkov committed May 20, 2024
1 parent e7f5f28 commit 883a951
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public static String uri(final String xmlBase, String dbName, String idPart,
{
//for xrefs, always use the simple URI strategy (human-readable)
//replace unsafe symbols with underscore
localPart = localPart.replaceAll("[^-\\w]", "_");
localPart = localPart.replaceAll("[^-\\w]", "_");//todo: e.g. "foo bar" and "foo&bar" result in the same value - can mess things up...
} else {
//replace the local part with its md5 hash string (32-byte)
localPart = ModelUtils.md5hex(localPart);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static Stream<Arguments> uri() {
arguments("http://bioregistry.io/pubchem.substance:12345", "", "pubchem-substance", "12345", SmallMoleculeReference.class),
//special symbols or spaces in the 'id' part get replaced with underscore in the URI
arguments("UX_Foo_Bar", null, null, "Foo Bar", UnificationXref.class),
arguments("UX_Foo_Bar", null, null, "Foo&Bar", UnificationXref.class), //todo: no good - makes the same URI, can mess things up...
arguments("UX_Foo_Bar", null, null, "Foo&Bar", UnificationXref.class), //todo: the same expected URI as above can be wrong/bug...
arguments("uniprot:W0C7J9", "", "UniProt", "W0C7J9", UnificationXref.class),
arguments("http://bioregistry.io/ncbitaxon:9606", null, "taxonomy", "9606", BioSource.class),
arguments("http://bioregistry.io/ncbitaxon:9606", null, "NCBI Taxonomy", "9606", BioSource.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public static Pattern controlsPhosphorylation()
* Pattern for a Protein controlling a reaction whose participant is a small molecule.
*
* @param blacklist a skip-list of ubiquitous molecules
* @param consumption true/false (TODO explain)
* @param consumption true/false
* @return the pattern
*/
public static Pattern controlsMetabolicCatalysis(Blacklist blacklist, boolean consumption)
Expand Down
11 changes: 0 additions & 11 deletions paxtools-console/src/main/java/org/biopax/paxtools/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -399,17 +399,6 @@ static void sifnxToSif(String inputFile, String outputFile) throws IOException {
writer.close();
}

static void integrate(String[] argv) throws IOException {
Model model1 = getModel(io, argv[1]);
Model model2 = getModel(io, argv[2]);

Integrator integrator = new Integrator(SimpleEditorMap.get(model1.getLevel()), model1, model2);
integrator.integrate();

io.setFactory(model1.getLevel().getDefaultFactory());
io.convertToOWL(model1, new FileOutputStream(argv[3]));
}

static void merge(String[] argv) throws IOException {
Model model1 = getModel(io, argv[1]);
Model model2 = getModel(io, argv[2]);
Expand Down
3 changes: 0 additions & 3 deletions paxtools-console/src/main/java/org/biopax/paxtools/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ enum Command {
toSBGN("<biopax.owl> <output.sbgn> [-nolayout]\n" +
"\t- converts model to the SBGN format and applies COSE layout unless optional -nolayout flag is set.")
{public void run(String[] argv) throws IOException { toSbgn(argv); } },
integrate("<file1> <file2> <output>\n" +
"\t- integrates file2 into file1 and writes it into output (experimental)")
{public void run(String[] argv) throws IOException{integrate(argv);} },
toLevel3("<input> <output> [-psimiToComplexes]\n" +
"\t- converts BioPAX level 1 or 2, PSI-MI 2.5 and PSI-MITAB to the level 3 file;\n" +
"\t-psimiToComplexes forces PSI-MI Interactions become BioPAX Complexes instead MolecularInteractions.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
* into the <em>target</em>.
*
* Please note that this class is in its beta state.
*
* @author Ozgun Babur
* @author Emek Demir
*
* @deprecated it's experimetal, only for Level2, and seems not tested/maintained
*/
@Deprecated
public class Integrator {

private static final Logger log = LoggerFactory.getLogger(Integrator.class);
Expand All @@ -48,10 +54,7 @@ public class Integrator {
* C | | | |
* ------------------------------
*/
private Map<physicalEntityParticipant,
Map<physicalEntityParticipant, Double>> pepScoreMatrix
= new HashMap<physicalEntityParticipant,
Map<physicalEntityParticipant, Double>>();
private Map<physicalEntityParticipant, Map<physicalEntityParticipant, Double>> pepScoreMatrix = new HashMap<>();

/**
* This is the pool where the scores and relevant conversions
Expand Down Expand Up @@ -114,17 +117,13 @@ public Integrator(EditorMap editorMap, Model target, Model... sources) {
log.info("Merging finished.");

if( isNormalizeModels() ) {
log.info("Normalizing models.");

log.info("Normaling XREFs.");
normalizeXrefs(target);
normalizeXrefs(mergedSources);
log.info("Normaling OCVs.");
normalizeOpenControlledVocabulary(mergedSources);
log.info("Normaling cellular locations.");
normalizeCellularLocations(mergedSources);

log.info("Normalization completed.");
}
}

Expand Down Expand Up @@ -296,21 +295,18 @@ public List<ConversionScore> integrate(List<ConversionScore> alternativeScores)
* Instead, we are going to copy them, and modify their copies.
*/
log.info("Creating a copy of the PEP scores.");
Map<physicalEntityParticipant,
Map<physicalEntityParticipant, Double>> copyMatrix
= new HashMap<physicalEntityParticipant, Map<physicalEntityParticipant, Double>>();
Map<physicalEntityParticipant, Map<physicalEntityParticipant, Double>> copyMatrix = new HashMap<>();
// Copy the contents of the matrix
for(physicalEntityParticipant pepKey: pepScoreMatrix.keySet()) {
copyMatrix.put(pepKey,
new HashMap<physicalEntityParticipant, Double>(pepScoreMatrix.get(pepKey)));
copyMatrix.put(pepKey, new HashMap<>(pepScoreMatrix.get(pepKey)));
}
// We want to use the copy now
pepScoreMatrix = copyMatrix;
log.info("PEP scores copied.");

similarConversions = (alternativeScores == null)
? new ArrayList<>(this.similarConversions)
: alternativeScores;
? new ArrayList<>(this.similarConversions)
: alternativeScores;

log.info("Conversion scores copied.");
/* End of copies */
Expand Down Expand Up @@ -347,7 +343,7 @@ private void equalizeEntities(List<ConversionScore> similarConversions) {

for(ConversionScore convScore: similarConversions) {
// Since we sorted the list, we are safe to break
// But a continue will also do the trick, mostly
// But a "continue;" would also do the trick, mostly
// requiring little more time
if( convScore.getScore() < getThreshold() )
break;
Expand Down Expand Up @@ -420,25 +416,8 @@ private void equalizeEntities(List<ConversionScore> similarConversions) {
}
}

/**
* @deprecated setRDFId/setUri is not available anymore
*/
@Deprecated
private void equalize(BioPAXElement e1, BioPAXElement e2) {
// Operation below is enough for the time being
// TODO re-factoring: setRDFId/setUri is not available anymore! (changing URIs directly is dangerous)
//e2.setUri(e1.getUri());

throw new UnsupportedOperationException("This needs re-factoring: bpe.setUri is not available anymore!");

//TODO ? use some alternative way to store that a1 equals e2, e.g., Set<String> matched,
//matched.add(e1.getUri()+e2.getUri()); matched.add(e2.getUri()+e1.getUri());
}

private boolean equals(BioPAXElement a, BioPAXElement b) {
throw new UnsupportedOperationException("not implemented yet.");
// TODO ? implement equals(BioPAXElement a, BioPAXElement b): can be smth. like the following... and use below
//return (a == null) ? b == null : a.equals(b) || matched.contains(a.getUri()+b.getUri());
ModelUtils.updateUri(null, e2, e1.getUri());
}

private void equalizePEP(physicalEntityParticipant controller1, physicalEntityParticipant controller2) {
Expand Down
2 changes: 1 addition & 1 deletion paxtools-core/src/test/resources/L3/skip.owl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test data inspired by several humancyc v24 data issues -->
<!-- Entity is non-instantiable; also term property value must be a string value,
preferably from MI ontology, e.g. "gene product" MI:0251 or "see-also", etc.
Right now (after latest code fix to prevent exception here), Entity is not entirely ignored, -
FIXME: its URI "http://biopax.org/tmp#Gene" becomes the value the term property value;
FIXME: its URI "http://biopax.org/tmp#Gene" becomes the term property value;
i.e. this is equivalent to <term>http://biopax.org/tmp#Gene</term> ... -->
<Entity rdf:ID="Gene">
<comment>comment1</comment>
Expand Down

0 comments on commit 883a951

Please sign in to comment.