Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure deterministic order in toConciseAlignmentString #908

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,37 @@
*/
package org.biojava.nbio.structure.align.util;

import org.biojava.nbio.structure.*;
import java.io.IOException;
import java.io.Writer;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.vecmath.Matrix4d;

import org.biojava.nbio.structure.Atom;
import org.biojava.nbio.structure.AtomImpl;
import org.biojava.nbio.structure.Calc;
import org.biojava.nbio.structure.Chain;
import org.biojava.nbio.structure.ChainImpl;
import org.biojava.nbio.structure.Group;
import org.biojava.nbio.structure.ResidueNumber;
import org.biojava.nbio.structure.Structure;
import org.biojava.nbio.structure.StructureException;
import org.biojava.nbio.structure.StructureImpl;
import org.biojava.nbio.structure.StructureTools;
import org.biojava.nbio.structure.align.AFPTwister;
import org.biojava.nbio.structure.align.ce.CECalculator;
import org.biojava.nbio.structure.align.fatcat.FatCatFlexible;
Expand All @@ -33,15 +63,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.Writer;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.vecmath.Matrix4d;

/**
* Methods for analyzing and manipulating AFPChains and for
* other pairwise alignment utilities. <p>
Expand Down Expand Up @@ -989,7 +1010,7 @@ public static Object resizeArray (Object oldArray, int newSize) {
*/
public static <S,T> String toConciseAlignmentString(Map<S,T> alignment, Map<T,S> identity) {
// Clone input to prevent changes
Map<S,T> alig = new HashMap<S,T>(alignment);
Map<S,T> alig = new TreeMap<S,T>(alignment);

// Generate inverse alignment
Map<S,List<S>> inverse = new HashMap<S,List<S>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private synchronized boolean addToZipFileSystem(Path zipFile, File[] files, Path
*/

// Copy in each file.
try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, null)) {
try (FileSystem zipfs = FileSystems.newFileSystem(zipFile, (ClassLoader) null)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line fixes an error I was getting compiling with Java 1.8:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project biojava-structure: Compilation failure
[ERROR] /Users/bliven_s/git/biojava_ws/biojava/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ZipChemCompProvider.java:[296,52] reference to newFileSystem is ambiguous
[ERROR]   both method newFileSystem(java.nio.file.Path,java.lang.ClassLoader) in java.nio.file.FileSystems and method newFileSystem(java.nio.file.Path,java.util.Map<java.lang.String,?>) in java.nio.file.FileSystems match

The second form isn't documented, so it could be that this change will cause a warning with different JDKs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbliven
I did initially try to fix this error with the same change. However the TreeMap here, is not fixing this flaky error. The tool still marks it as flaky with error of the sort -

[ERROR] Failures: 
[ERROR]   AlignmentToolsTest.testToConciseAlignmentString:342 1. Cycles. expected:<[1>2>3>1] 7>7> but was:<[2>3>1>2] 7>7>
[INFO] 
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Copy link
Contributor

@Vidishab18 Vidishab18 Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbliven @josemduarte

Would like to link the Nondex tool here : https://github.com/TestingResearchIllinois/NonDex

The tool requires :

  • Adding the plugin as specified in the documentation which applies if you want to run NonDex mutliple times.

  • Run for the test -
    mvn -pl biojava-integrationtest nondex:nondex -Dtest=AlignmentToolsTest#testToConciseAlignmentString

  • Run for the whole module -
    mvn -pl biojava-integrationtest nondex:nondex.

  • Otherwise, one need not add the plugin to pom.xml file(s) and can run just run mvn edu.illinois:nondex-maven-plugin:1.1.2:nondex instead of mvn test. Please check that the command does work for you.

This could be added into travis.yml, so it can be run on new tests too.

It also has the debug feature that can be used to point to the file(s) that could require changes. The link to the tool has all the documentation.

Files.createDirectories(pathWithinArchive);
for (File f : files) {
if (!f.isDirectory() && f.exists()) {
Expand Down