From 1fe5059a32d32ef7f47b015bc5b71d58bc02bfc9 Mon Sep 17 00:00:00 2001 From: Spencer Bliven Date: Mon, 7 Dec 2020 16:39:14 +0100 Subject: [PATCH] Ensure deterministic order in toConciseAlignmentString Fixes #907 --- .../structure/align/util/AlignmentTools.java | 43 ++++++++++++++----- .../io/mmcif/ZipChemCompProvider.java | 2 +- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java index f7660e2097..b35e80f941 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AlignmentTools.java @@ -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; @@ -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.

@@ -989,7 +1010,7 @@ public static Object resizeArray (Object oldArray, int newSize) { */ public static String toConciseAlignmentString(Map alignment, Map identity) { // Clone input to prevent changes - Map alig = new HashMap(alignment); + Map alig = new TreeMap(alignment); // Generate inverse alignment Map> inverse = new HashMap>(); diff --git a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ZipChemCompProvider.java b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ZipChemCompProvider.java index 9475a6d036..c6d14699d2 100644 --- a/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ZipChemCompProvider.java +++ b/biojava-structure/src/main/java/org/biojava/nbio/structure/io/mmcif/ZipChemCompProvider.java @@ -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)) { Files.createDirectories(pathWithinArchive); for (File f : files) { if (!f.isDirectory() && f.exists()) {