diff --git a/README.md b/README.md index 610321db..433ee17e 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,21 @@ # Mean of Circular Quantities (MCQ) Mean of Circular Quantities (MCQ) is a dissimilarity measure useful in comparison of 3D protein and/or RNA structures. It calculates an average difference between corresponding torsion angle values (rotations around bonds). More information can be found in: + > Zok, T., Popenda, M., & Szachniuk, M. (2014). MCQ4Structures to compute similarity of molecule structures. Central European Journal of Operations Research, 22(3), 457–473. https://doi.org/10.1007/s10100-013-0296-5 ## Installation ```sh -git clone https://github.com/RNA-Puzzles/mcq-parent -cd mcq-parent -git submodule update --init +git clone https://github.com/tzok/mcq4structures.git +cd mcq4structures mvn install ``` ## Contents This project consists of a few subprojets: + - `mcq-common`: base functionality - `mcq-clustering`: partitional and hierarchical clustering - `mcq-cli`: command-line interface diff --git a/mcq-cli/pom.xml b/mcq-cli/pom.xml index e37ffdbe..85e0124d 100644 --- a/mcq-cli/pom.xml +++ b/mcq-cli/pom.xml @@ -5,7 +5,7 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 mcq-cli @@ -78,6 +78,11 @@ + + com.diffplug.spotless + spotless-maven-plugin + + com.github.ekryd.sortpom sortpom-maven-plugin diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java index 3c0edec3..4005f06b 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Global.java @@ -1,5 +1,14 @@ package pl.poznan.put.mcq.cli; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.List; +import java.util.Locale; +import java.util.stream.Collectors; import me.tongfei.progressbar.ProgressBar; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; @@ -27,16 +36,6 @@ import pl.poznan.put.utility.svg.Format; import pl.poznan.put.utility.svg.SVGHelper; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.util.List; -import java.util.Locale; -import java.util.stream.Collectors; - @SuppressWarnings("UseOfSystemOutOrSystemErr") @Value.Immutable public abstract class Global { diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Helper.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Helper.java index 47293b9e..b0561c8f 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Helper.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Helper.java @@ -1,5 +1,19 @@ package pl.poznan.put.mcq.cli; +import java.io.File; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.ResourceBundle; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import lombok.extern.slf4j.Slf4j; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; @@ -14,27 +28,18 @@ import pl.poznan.put.matching.SelectionQuery; import pl.poznan.put.matching.StructureSelection; import pl.poznan.put.pdb.PdbParsingException; +import pl.poznan.put.pdb.analysis.ImmutableDefaultResidueCollection; import pl.poznan.put.pdb.analysis.ImmutablePdbCompactFragment; import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.pdb.analysis.PdbChain; import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.pdb.analysis.PdbResidue; import pl.poznan.put.pdb.analysis.ResidueCollection; import pl.poznan.put.rna.NucleotideTorsionAngle; import pl.poznan.put.structure.StructureManager; import pl.poznan.put.torsion.MasterTorsionAngleType; -import java.io.File; -import java.io.IOException; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.ResourceBundle; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - @Slf4j final class Helper { static final Option OPTION_TARGET = @@ -72,7 +77,8 @@ final class Helper { .numberOfArgs(1) .desc( String.format( - "Torsion angle types (separated by comma without space), select from: %s. Default is: %s", + "Torsion angle types (separated by comma without space), select from: %s. Default" + + " is: %s", Helper.arrayToString(NucleotideTorsionAngle.values()), Helper.arrayToString( MoleculeType.RNA.mainAngleTypes().toArray(new MasterTorsionAngleType[0])))) @@ -94,9 +100,12 @@ final class Helper { .build(); static final Option OPTION_RELAXED = Option.builder("r") - .longOpt("relaxed") + .longOpt("relaxed-mode") + .numberOfArgs(1) .desc( - "Turn on relaxed mode (process 3D models even in presence of bond lengths' violations and treat each chain as a compact fragment even with gaps)") + "Relaxed mode. 0 = (default) does not compare if any violation is found. 1 = only" + + " compare models without violations. 2 = compare everything regardless of any" + + " violations") .build(); static final Option OPTION_MULTI_MODEL = Option.builder("m") @@ -120,8 +129,7 @@ static StructureSelection selectModel(final CommandLine commandLine) throws Pars final String selectionQuery = (String) commandLine.getParsedOptionValue(Helper.OPTION_SELECTION_MODEL.getOpt()); final String name = Helper.modelName(modelFile, model); - return Helper.select( - model, name, selectionQuery, commandLine.hasOption(Helper.OPTION_RELAXED.getOpt())); + return Helper.select(model, name, selectionQuery, Helper.parseRelaxedMode(commandLine)); } static List selectModels(final CommandLine commandLine) @@ -139,10 +147,7 @@ static List selectModels(final CommandLine commandLine) final String name = pathToName.getOrDefault(path, Helper.modelName(new File(path), model)); return Helper.select( - model, - name, - selectionQuery, - commandLine.hasOption(Helper.OPTION_RELAXED.getOpt())); + model, name, selectionQuery, Helper.parseRelaxedMode(commandLine)); }) .collect(Collectors.toList()); } @@ -153,8 +158,7 @@ static StructureSelection selectTarget(final CommandLine commandLine) throws Par final String selectionQuery = (String) commandLine.getParsedOptionValue(Helper.OPTION_SELECTION_TARGET.getOpt()); final String name = Helper.modelName(targetFile, target); - return Helper.select( - target, name, selectionQuery, commandLine.hasOption(Helper.OPTION_RELAXED.getOpt())); + return Helper.select(target, name, selectionQuery, Helper.parseRelaxedMode(commandLine)); } public static List loadMultiModelFile(final CommandLine commandLine) @@ -166,7 +170,6 @@ public static List loadMultiModelFile(final CommandLine comm Helper.OPTION_MULTI_MODEL.getOpt(), MultiModelMode.FIRST.name())); final String query = (String) commandLine.getParsedOptionValue(Helper.OPTION_SELECTION_TARGET.getOpt()); - final boolean relaxedMode = commandLine.hasOption(Helper.OPTION_RELAXED.getOpt()); return Helper.loadStructures(modelFile, multiModelMode).stream() .map( @@ -179,7 +182,7 @@ public static List loadMultiModelFile(final CommandLine comm Helper.modelName(modelFile, model), model.modelNumber()), query, - relaxedMode)) + Helper.parseRelaxedMode(commandLine))) .collect(Collectors.toList()); } @@ -275,18 +278,33 @@ private static List loadStructures( * @param structure A PDB structure. * @param name Name of the structure to be displayed in final results. * @param query An asterisk, empty string or selection query. - * @param relaxedMode If true, then each chain is treated as a single compact fragment (gaps are - * not taken into account). + * @param relaxedMode If relaxed mode is MEDIUM or FULL, then each chain is treated as a single + * compact fragment (gaps are not taken into account). * @return A {@link StructureSelection} made on the given structure. */ private static StructureSelection select( - final PdbModel structure, final String name, final String query, final boolean relaxedMode) { - if (relaxedMode) { - return new StructureSelection( - name, + final PdbModel structure, + final String name, + final String query, + final Local.RelaxedMode relaxedMode) { + if (relaxedMode == Local.RelaxedMode.MEDIUM || relaxedMode == Local.RelaxedMode.FULL) { + final LinkedHashSet uniqueChains = structure.chains().stream() - .map(chain -> Helper.residueCollectionToCompactFragment(chain, name)) - .collect(Collectors.toList())); + .map(PdbChain::identifier) + .collect(Collectors.toCollection(LinkedHashSet::new)); + final List compactFragments = new ArrayList<>(); + + for (final String uniqueChain : uniqueChains) { + final List chainResidues = + structure.residues().stream() + .filter(pdbResidue -> Objects.equals(uniqueChain, pdbResidue.chainIdentifier())) + .collect(Collectors.toList()); + compactFragments.add( + Helper.residueCollectionToCompactFragment( + ImmutableDefaultResidueCollection.of(chainResidues), name)); + } + + return new StructureSelection(name, compactFragments); } if ("*".equals(query)) { @@ -346,4 +364,18 @@ private static String getMessage(final String s) { private static String formatMessage(final String s, final Object... objects) { return MessageFormat.format(Helper.getMessage(s), objects); } + + public static Local.RelaxedMode parseRelaxedMode(final CommandLine commandLine) { + if (commandLine.hasOption(Helper.OPTION_RELAXED.getOpt())) { + final String optionValue = commandLine.getOptionValue(Helper.OPTION_RELAXED.getOpt()); + if ("0".equals(optionValue)) { + return Local.RelaxedMode.NONE; + } else if ("1".equals(optionValue)) { + return Local.RelaxedMode.MEDIUM; + } else if ("2".equals(optionValue)) { + return Local.RelaxedMode.FULL; + } + } + return Local.RelaxedMode.NONE; + } } diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Local.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Local.java index d381ff65..6f520e22 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Local.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Local.java @@ -1,5 +1,13 @@ package pl.poznan.put.mcq.cli; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.file.Path; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -37,22 +45,15 @@ import pl.poznan.put.utility.svg.Format; import pl.poznan.put.utility.svg.SVGHelper; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.Set; -import java.util.TreeSet; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - @SuppressWarnings({"CallToSystemExit", "UseOfSystemOutOrSystemErr"}) @Value.Immutable public abstract class Local { + public enum RelaxedMode { + NONE, + MEDIUM, + FULL + } + private static final Options OPTIONS = new Options() .addOption(Helper.OPTION_TARGET) @@ -76,9 +77,10 @@ public static void main(final String[] args) throws ParseException { final List models = Helper.selectModels(commandLine); final List angleTypes = Helper.parseAngles(commandLine); final File outputDirectory = Helper.getOutputDirectory(commandLine); - final boolean isRelaxed = commandLine.hasOption(Helper.OPTION_RELAXED.getOpt()); + final RelaxedMode relaxedMode = Helper.parseRelaxedMode(commandLine); + final Local local = - ImmutableLocal.of(target, models, angleTypes, outputDirectory.toPath(), isRelaxed); + ImmutableLocal.of(target, models, angleTypes, outputDirectory.toPath(), relaxedMode); local.compare(); } @@ -172,7 +174,7 @@ private static void exportSecondaryStructureImage( public abstract Path outputDirectory(); @Value.Parameter(order = 5) - public abstract boolean isRelaxed(); + public abstract RelaxedMode relaxedMode(); @Value.Lazy protected LocalComparator mcq() { @@ -200,9 +202,55 @@ protected Local validate() { Validate.isTrue(outputDirectory().toFile().isDirectory(), "The output path is not a directory"); // check validity of comparison - checkBondLengthViolations(); - checkFragmentCountViolations(); - checkResidueCountViolations(); + final List invalidBondLengths = checkBondLengthViolations(); + if (!invalidBondLengths.isEmpty()) { + if (relaxedMode() == RelaxedMode.NONE) { + System.err.println("Found bond lengths violations, cannot continue"); + } else if (relaxedMode() == RelaxedMode.MEDIUM) { + System.err.println("Found bond lengths violations, proceed to remove invalid models"); + return ImmutableLocal.copyOf(this) + .withModels( + models().stream() + .filter(model -> !invalidBondLengths.contains(model)) + .collect(Collectors.toList())); + } else { + System.err.println( + "Found bond lengths violations, but will continue full comparison anyway"); + } + } + + final List invalidFragmentCount = checkFragmentCountViolations(); + if (!invalidFragmentCount.isEmpty()) { + if (relaxedMode() == RelaxedMode.NONE) { + System.err.println("Found invalid fragment count, cannot continue"); + } else if (relaxedMode() == RelaxedMode.MEDIUM) { + System.err.println("Found invalid fragment count, proceed to remove invalid models"); + return ImmutableLocal.copyOf(this) + .withModels( + models().stream() + .filter(model -> !invalidFragmentCount.contains(model)) + .collect(Collectors.toList())); + } else { + System.err.println( + "Found invalid fragment count, but will continue full comparison anyway"); + } + } + + final List invalidResidueCount = checkResidueCountViolations(); + if (!invalidResidueCount.isEmpty()) { + if (relaxedMode() == RelaxedMode.NONE) { + System.err.println("Found invalid residue count, cannot continue"); + } else if (relaxedMode() == RelaxedMode.MEDIUM) { + System.err.println("Found invalid residue count, proceed to remove invalid models"); + return ImmutableLocal.copyOf(this) + .withModels( + models().stream() + .filter(model -> !invalidResidueCount.contains(model)) + .collect(Collectors.toList())); + } else { + System.err.println("Found invalid residue count, but will continue full comparison anyway"); + } + } return this; } @@ -242,10 +290,11 @@ private void compare() { .collect(Collectors.toList()); // generate ranking - final Set> ranking = + final List> ranking = IntStream.range(0, models().size()) .mapToObj(i -> Pair.of(mcqs.get(i).degrees(), models().get(i))) - .collect(Collectors.toCollection(TreeSet::new)); + .sorted(Comparator.comparingDouble(Pair::getLeft)) + .collect(Collectors.toList()); for (final Pair pair : ranking) { System.out.printf(Locale.US, "%s %.2f%n", pair.getValue().getName(), pair.getKey()); @@ -318,7 +367,7 @@ private void exportModelResults(final FragmentMatch fragmentMatch) { } } - private void checkResidueCountViolations() { + private List checkResidueCountViolations() { // check for size final List invalidCompactFragments = models().stream() @@ -342,32 +391,18 @@ private void checkResidueCountViolations() { .forEach( i -> System.err.printf( - "Invalid size (%d) of fragment `%s`. Expected size (%d) taken from fragment `%s`%n", + "Invalid size (%d) of fragment `%s`. Expected size (%d) taken from" + + " fragment `%s`%n", model.getCompactFragments().get(i).residues().size(), model.getCompactFragments().get(i).name(), target().getCompactFragments().get(i).residues().size(), target().getCompactFragments().get(i).name()))); - - handleInvalidModels(invalidCompactFragments); } - } - private void handleInvalidModels(final Collection invalidModels) { - if (isRelaxed()) { - System.err.println("Removing invalid models from further processing"); - models().removeAll(invalidModels); - - if (models().isEmpty()) { - System.err.println("All models are invalid, cannot continue"); - System.exit(1); - } - } else { - System.err.println("Some models are invalid, cannot continue"); - System.exit(1); - } + return invalidCompactFragments; } - private void checkFragmentCountViolations() { + private List checkFragmentCountViolations() { // check for gaps final int fragmentCount = target().getCompactFragments().size(); final List invalidModels = @@ -377,18 +412,21 @@ private void checkFragmentCountViolations() { if (!invalidModels.isEmpty()) { printFragmentDetails(invalidModels); - - handleInvalidModels(invalidModels); } + + return invalidModels; } - private void checkBondLengthViolations() { + private List checkBondLengthViolations() { final StringBuilder builder = new StringBuilder(); + final List invalidModels = new ArrayList<>(); for (final StructureSelection model : models()) { final List violations = model.findBondLengthViolations(); if (!violations.isEmpty()) { + invalidModels.add(model); + builder.append("Found bond length violations in ").append(model.getName()).append(":\n"); violations.forEach(violation -> builder.append("- ").append(violation).append('\n')); builder.append('\n'); @@ -396,5 +434,6 @@ private void checkBondLengthViolations() { } System.err.print(builder); + return invalidModels; } } diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/MCD.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/MCD.java index 7da58a0f..4b428c70 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/MCD.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/MCD.java @@ -1,5 +1,8 @@ package pl.poznan.put.mcq.cli; +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; import org.apache.commons.cli.Option; @@ -13,10 +16,6 @@ import pl.poznan.put.pdb.analysis.PdbModel; import pl.poznan.put.pdb.analysis.PdbParser; -import java.io.File; -import java.io.IOException; -import java.nio.charset.StandardCharsets; - public class MCD { public static void main(final String[] args) throws ParseException, IOException { final Options options = new Options(); diff --git a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Print.java b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Print.java index ca980a33..f2fd09ca 100644 --- a/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Print.java +++ b/mcq-cli/src/main/java/pl/poznan/put/mcq/cli/Print.java @@ -1,6 +1,12 @@ package pl.poznan.put.mcq.cli; import com.github.slugify.Slugify; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.List; +import java.util.Locale; +import java.util.stream.Stream; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.DefaultParser; @@ -24,13 +30,6 @@ import pl.poznan.put.structure.formats.ImmutableDefaultDotBracketFromPdb; import pl.poznan.put.torsion.MasterTorsionAngleType; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.List; -import java.util.Locale; -import java.util.stream.Stream; - @SuppressWarnings("UseOfSystemOutOrSystemErr") public final class Print { private static final Options OPTIONS = @@ -66,8 +65,7 @@ public static void main(final String[] args) throws ParseException, IOException final CSVFormat format = CSVFormat.Builder.create().setHeader(Print.CSV_HEADER).build(); try (final FileWriter writer = new FileWriter(csvFile); - final CSVPrinter csvPrinter = - new CSVPrinter(writer, format)) { + final CSVPrinter csvPrinter = new CSVPrinter(writer, format)) { final DotBracketFromPdb dotBracket = Print.toDotBracket(model); for (final PdbCompactFragment fragment : model.getCompactFragments()) { diff --git a/mcq-clustering/pom.xml b/mcq-clustering/pom.xml index 558efd89..51bb7db7 100644 --- a/mcq-clustering/pom.xml +++ b/mcq-clustering/pom.xml @@ -5,7 +5,7 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 mcq-clustering @@ -62,6 +62,11 @@ + + com.diffplug.spotless + spotless-maven-plugin + + com.github.ekryd.sortpom sortpom-maven-plugin diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Cluster.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Cluster.java index deda9cb9..93b92e5e 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Cluster.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Cluster.java @@ -1,10 +1,9 @@ package pl.poznan.put.clustering.hierarchical; -import lombok.EqualsAndHashCode; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import lombok.EqualsAndHashCode; @EqualsAndHashCode public class Cluster { diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Clusterer.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Clusterer.java index f92f27ac..a73652da 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Clusterer.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/Clusterer.java @@ -1,11 +1,10 @@ package pl.poznan.put.clustering.hierarchical; -import org.apache.commons.lang3.tuple.Pair; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; +import org.apache.commons.lang3.tuple.Pair; public final class Clusterer { private final List names; diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/HierarchicalClustering.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/HierarchicalClustering.java index f41d82b9..42497b67 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/HierarchicalClustering.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/hierarchical/HierarchicalClustering.java @@ -1,14 +1,5 @@ package pl.poznan.put.clustering.hierarchical; -import org.apache.batik.svggen.SVGGraphics2D; -import org.apache.batik.util.SVGConstants; -import org.apache.commons.lang3.NotImplementedException; -import org.apache.commons.lang3.tuple.Pair; -import org.w3c.dom.Element; -import org.w3c.dom.svg.SVGDocument; -import pl.poznan.put.interfaces.Visualizable; -import pl.poznan.put.utility.svg.SVGHelper; - import java.awt.FontMetrics; import java.awt.font.LineMetrics; import java.awt.geom.Rectangle2D; @@ -17,6 +8,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.batik.svggen.SVGGraphics2D; +import org.apache.batik.util.SVGConstants; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.commons.lang3.tuple.Pair; +import org.w3c.dom.Element; +import org.w3c.dom.svg.SVGDocument; +import pl.poznan.put.interfaces.Visualizable; +import pl.poznan.put.utility.svg.SVGHelper; public class HierarchicalClustering implements Visualizable { private final List names; diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KMedoids.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KMedoids.java index cd4b14fe..cc5c1984 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KMedoids.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KMedoids.java @@ -1,11 +1,10 @@ package pl.poznan.put.clustering.partitional; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.text.DecimalFormat; import java.util.Collection; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class KMedoids implements PrototypeBasedClusterer { private static final Logger LOGGER = LoggerFactory.getLogger(KMedoids.class); diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KScanner.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KScanner.java index 59bcedeb..650ed777 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KScanner.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/KScanner.java @@ -1,14 +1,13 @@ package pl.poznan.put.clustering.partitional; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorCompletionService; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class KScanner { private static final Logger LOGGER = LoggerFactory.getLogger(KScanner.class); diff --git a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/PartitionalClustering.java b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/PartitionalClustering.java index b8e99f89..f1345785 100644 --- a/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/PartitionalClustering.java +++ b/mcq-clustering/src/main/java/pl/poznan/put/clustering/partitional/PartitionalClustering.java @@ -1,13 +1,5 @@ package pl.poznan.put.clustering.partitional; -import org.jcolorbrewer.ColorBrewer; -import org.jumpmind.symmetric.csv.CsvWriter; -import org.w3c.dom.svg.SVGDocument; -import pl.poznan.put.interfaces.Exportable; -import pl.poznan.put.interfaces.Visualizable; -import pl.poznan.put.svg.MDSDrawer; -import pl.poznan.put.types.DistanceMatrix; - import java.awt.Color; import java.io.File; import java.io.IOException; @@ -17,6 +9,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.jcolorbrewer.ColorBrewer; +import org.jumpmind.symmetric.csv.CsvWriter; +import org.w3c.dom.svg.SVGDocument; +import pl.poznan.put.interfaces.Exportable; +import pl.poznan.put.interfaces.Visualizable; +import pl.poznan.put.svg.MDSDrawer; +import pl.poznan.put.types.DistanceMatrix; public class PartitionalClustering implements Visualizable, Exportable { private final Map clusterColor = new HashMap<>(); diff --git a/mcq-clustering/src/test/java/pl/poznan/put/clustering/hierarchical/ClustererTest.java b/mcq-clustering/src/test/java/pl/poznan/put/clustering/hierarchical/ClustererTest.java index d9432dd5..25ef7f29 100644 --- a/mcq-clustering/src/test/java/pl/poznan/put/clustering/hierarchical/ClustererTest.java +++ b/mcq-clustering/src/test/java/pl/poznan/put/clustering/hierarchical/ClustererTest.java @@ -1,14 +1,13 @@ package pl.poznan.put.clustering.hierarchical; -import org.junit.Test; - -import java.util.Arrays; -import java.util.List; - import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import java.util.Arrays; +import java.util.List; +import org.junit.Test; + public class ClustererTest { private static final double EPSILON = 1.0e-3; diff --git a/mcq-clustering/src/test/java/pl/poznan/put/clustering/partitional/KMedoidsTest.java b/mcq-clustering/src/test/java/pl/poznan/put/clustering/partitional/KMedoidsTest.java index 0b0849d3..c2428fc8 100644 --- a/mcq-clustering/src/test/java/pl/poznan/put/clustering/partitional/KMedoidsTest.java +++ b/mcq-clustering/src/test/java/pl/poznan/put/clustering/partitional/KMedoidsTest.java @@ -1,15 +1,14 @@ package pl.poznan.put.clustering.partitional; -import org.junit.Assert; -import org.junit.Test; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; +import org.junit.Assert; +import org.junit.Test; public class KMedoidsTest { private static final double EPSILON = 1.0e-3; diff --git a/mcq-core/pom.xml b/mcq-core/pom.xml index 1d5421fb..766bfd71 100644 --- a/mcq-core/pom.xml +++ b/mcq-core/pom.xml @@ -5,12 +5,17 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 mcq-core + + + com.github.tzok + varna-tz + commons-io commons-io @@ -56,11 +61,6 @@ BioCommons - - com.github.tzok - varna-tz - - org.immutables value @@ -100,6 +100,11 @@ + + com.diffplug.spotless + spotless-maven-plugin + + com.github.ekryd.sortpom sortpom-maven-plugin diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/LCS.java b/mcq-core/src/main/java/pl/poznan/put/comparison/LCS.java index dfdb2627..72042d35 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/LCS.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/LCS.java @@ -1,5 +1,8 @@ package pl.poznan.put.comparison; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import lombok.Getter; import lombok.RequiredArgsConstructor; import org.apache.commons.math3.util.FastMath; @@ -23,10 +26,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.torsion.TorsionAngleDelta; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - /** * Implementation of LCS global similarity measure based on torsion angle representation. * diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/MCD.java b/mcq-core/src/main/java/pl/poznan/put/comparison/MCD.java index b955cd1d..898d67aa 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/MCD.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/MCD.java @@ -1,5 +1,6 @@ package pl.poznan.put.comparison; +import java.util.List; import org.apache.commons.math3.util.FastMath; import org.immutables.value.Value; import pl.poznan.put.circular.Angle; @@ -16,8 +17,6 @@ import pl.poznan.put.pdb.analysis.ResidueTorsionAngles; import pl.poznan.put.torsion.MasterTorsionAngleType; -import java.util.List; - @Value.Immutable public abstract class MCD implements GlobalComparator { @Value.Parameter(order = 1) diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/MCQ.java b/mcq-core/src/main/java/pl/poznan/put/comparison/MCQ.java index 381cdcbc..f09d808d 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/MCQ.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/MCQ.java @@ -1,5 +1,8 @@ package pl.poznan.put.comparison; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; import org.immutables.value.Value; import pl.poznan.put.circular.Angle; import pl.poznan.put.circular.samples.ImmutableAngleSample; @@ -23,10 +26,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.torsion.TorsionAngleDelta; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - /** * Implementation of MCQ global similarity measure based on torsion angle representation. * diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/global/GlobalMatrix.java b/mcq-core/src/main/java/pl/poznan/put/comparison/global/GlobalMatrix.java index cc789e7b..ed902ad2 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/global/GlobalMatrix.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/global/GlobalMatrix.java @@ -1,5 +1,15 @@ package pl.poznan.put.comparison.global; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import javax.swing.table.TableModel; import lombok.Getter; import org.apache.commons.math3.linear.Array2DRowRealMatrix; import org.apache.commons.math3.linear.RealMatrix; @@ -11,17 +21,6 @@ import pl.poznan.put.utility.NonEditableDefaultTableModel; import pl.poznan.put.utility.TabularExporter; -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Locale; - @Getter public class GlobalMatrix implements Clusterable, Exportable, Tabular { private final DistanceMatrix distanceMatrix; diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/global/LCSGlobalResult.java b/mcq-core/src/main/java/pl/poznan/put/comparison/global/LCSGlobalResult.java index eb52553e..cb639f6e 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/global/LCSGlobalResult.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/global/LCSGlobalResult.java @@ -60,7 +60,15 @@ public final String cliOutput(final StructureSelection model, final StructureSel .get(selectionMatch.getFragmentMatches().get(0).getResidueComparisons().size() - 1) .model(); return String.format( - "MCQ value: %s\nNumber of residues: %d\nCoverage: %s%% \nTarget name: %s\nFirst target residue: %s\nLast target residue: %s\nModel name: %s\nFirst model residue: %s\nLast model residue: %s", + "MCQ value: %s\n" + + "Number of residues: %d\n" + + "Coverage: %s%% \n" + + "Target name: %s\n" + + "First target residue: %s\n" + + "Last target residue: %s\n" + + "Model name: %s\n" + + "First model residue: %s\n" + + "Last model residue: %s", shortDisplayName(), validCount, NumberFormatUtils.threeDecimalDigits().format(coverage), diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/global/MCDGlobalResult.java b/mcq-core/src/main/java/pl/poznan/put/comparison/global/MCDGlobalResult.java index be8cf724..8151df11 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/global/MCDGlobalResult.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/global/MCDGlobalResult.java @@ -1,10 +1,9 @@ package pl.poznan.put.comparison.global; +import java.util.Locale; import org.immutables.value.Value; import pl.poznan.put.matching.SelectionMatch; -import java.util.Locale; - @Value.Immutable public abstract class MCDGlobalResult implements GlobalResult { @Value.Parameter(order = 2) diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/global/ParallelGlobalComparator.java b/mcq-core/src/main/java/pl/poznan/put/comparison/global/ParallelGlobalComparator.java index cccd63e1..0a6a3ee2 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/global/ParallelGlobalComparator.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/global/ParallelGlobalComparator.java @@ -1,10 +1,5 @@ package pl.poznan.put.comparison.global; -import lombok.Data; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pl.poznan.put.matching.StructureSelection; - import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; @@ -14,6 +9,10 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Collectors; import java.util.stream.IntStream; +import lombok.Data; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import pl.poznan.put.matching.StructureSelection; public class ParallelGlobalComparator extends Thread { private static final Logger LOGGER = LoggerFactory.getLogger(ParallelGlobalComparator.class); diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalComparator.java b/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalComparator.java index 2ae91722..66aa9990 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalComparator.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalComparator.java @@ -1,10 +1,9 @@ package pl.poznan.put.comparison.local; +import java.util.List; import pl.poznan.put.matching.StructureSelection; import pl.poznan.put.pdb.analysis.PdbCompactFragment; -import java.util.List; - public interface LocalComparator { LocalResult comparePair(StructureSelection target, StructureSelection model); diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalResult.java b/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalResult.java index 1c222ffa..12ac8517 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalResult.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/local/LocalResult.java @@ -1,5 +1,14 @@ package pl.poznan.put.comparison.local; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; +import javax.swing.table.TableModel; import org.apache.commons.lang3.time.DateFormatUtils; import pl.poznan.put.interfaces.Exportable; import pl.poznan.put.interfaces.Tabular; @@ -12,16 +21,6 @@ import pl.poznan.put.utility.NonEditableDefaultTableModel; import pl.poznan.put.utility.TabularExporter; -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - public interface LocalResult extends Exportable, Tabular { SelectionMatch selectionMatch(); diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/local/MCQLocalResult.java b/mcq-core/src/main/java/pl/poznan/put/comparison/local/MCQLocalResult.java index 053f7a08..58938c2a 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/local/MCQLocalResult.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/local/MCQLocalResult.java @@ -1,25 +1,9 @@ package pl.poznan.put.comparison.local; -import org.apache.commons.lang3.time.DateFormatUtils; +import java.util.List; import org.immutables.value.Value; -import pl.poznan.put.matching.FragmentComparison; -import pl.poznan.put.matching.FragmentMatch; -import pl.poznan.put.matching.ResidueComparison; import pl.poznan.put.matching.SelectionMatch; import pl.poznan.put.torsion.MasterTorsionAngleType; -import pl.poznan.put.torsion.TorsionAngleDelta; -import pl.poznan.put.utility.NonEditableDefaultTableModel; -import pl.poznan.put.utility.TabularExporter; - -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; @Value.Immutable public abstract class MCQLocalResult implements LocalResult { diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/local/ModelsComparisonResult.java b/mcq-core/src/main/java/pl/poznan/put/comparison/local/ModelsComparisonResult.java index b29a2e9d..7bcc33f1 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/local/ModelsComparisonResult.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/local/ModelsComparisonResult.java @@ -1,25 +1,13 @@ package pl.poznan.put.comparison.local; +import java.util.List; +import java.util.stream.Collectors; import org.immutables.value.Value; -import pl.poznan.put.circular.Angle; -import pl.poznan.put.circular.ImmutableAngle; -import pl.poznan.put.circular.samples.ImmutableAngleSample; -import pl.poznan.put.matching.FragmentComparison; import pl.poznan.put.matching.FragmentMatch; -import pl.poznan.put.matching.ImmutableResidueComparison; -import pl.poznan.put.matching.ResidueComparison; import pl.poznan.put.pdb.analysis.MoleculeType; import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.torsion.ImmutableAverageTorsionAngleType; import pl.poznan.put.torsion.MasterTorsionAngleType; -import pl.poznan.put.torsion.TorsionAngleDelta; -import pl.poznan.put.torsion.TorsionAngleType; -import pl.poznan.put.torsion.range.RangeDifference; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; @Value.Immutable public abstract class ModelsComparisonResult { diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/local/SelectedAngle.java b/mcq-core/src/main/java/pl/poznan/put/comparison/local/SelectedAngle.java index 9d0bb483..cd16b67b 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/local/SelectedAngle.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/local/SelectedAngle.java @@ -1,5 +1,16 @@ package pl.poznan.put.comparison.local; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import javax.swing.table.TableModel; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; @@ -21,18 +32,6 @@ import pl.poznan.put.torsion.TorsionAngleDelta; import pl.poznan.put.utility.NonEditableDefaultTableModel; -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - @Data @Slf4j public class SelectedAngle implements Exportable, Tabular, MatchCollection { diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/AngleDeltaMapper.java b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/AngleDeltaMapper.java index 057d3576..a85e825e 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/AngleDeltaMapper.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/AngleDeltaMapper.java @@ -1,5 +1,8 @@ package pl.poznan.put.comparison.mapping; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import pl.poznan.put.circular.Angle; import pl.poznan.put.circular.samples.AngleSample; import pl.poznan.put.circular.samples.ImmutableAngleSample; @@ -7,10 +10,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.torsion.TorsionAngleDelta; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - /** Map {@link TorsionAngleDelta} onto 0-1 scale. */ public final class AngleDeltaMapper implements ComparisonMapper { private static final AngleDeltaMapper INSTANCE = new AngleDeltaMapper(); diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/ComparisonMapper.java b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/ComparisonMapper.java index 8083f41c..f906f75a 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/ComparisonMapper.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/ComparisonMapper.java @@ -1,10 +1,9 @@ package pl.poznan.put.comparison.mapping; +import java.util.List; import pl.poznan.put.matching.ResidueComparison; import pl.poznan.put.torsion.MasterTorsionAngleType; -import java.util.List; - /** * An interface for different methods which use information about residue comparison results and map * this into 0-1 range for Varna to visualize. diff --git a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/RangeDifferenceMapper.java b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/RangeDifferenceMapper.java index a7cb6a72..e1c0d05c 100644 --- a/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/RangeDifferenceMapper.java +++ b/mcq-core/src/main/java/pl/poznan/put/comparison/mapping/RangeDifferenceMapper.java @@ -1,12 +1,11 @@ package pl.poznan.put.comparison.mapping; +import java.util.List; import pl.poznan.put.matching.ResidueComparison; import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.torsion.TorsionAngleDelta; import pl.poznan.put.torsion.range.RangeDifference; -import java.util.List; - /** Map {@link RangeDifference} onto 0-1 scale. */ public final class RangeDifferenceMapper implements ComparisonMapper { private static final RangeDifferenceMapper INSTANCE = new RangeDifferenceMapper(); diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/AngleDeltaIterator.java b/mcq-core/src/main/java/pl/poznan/put/matching/AngleDeltaIterator.java index 55ed6762..599d7b11 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/AngleDeltaIterator.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/AngleDeltaIterator.java @@ -1,8 +1,7 @@ package pl.poznan.put.matching; -import pl.poznan.put.circular.Angle; - import java.util.Iterator; +import pl.poznan.put.circular.Angle; public interface AngleDeltaIterator extends Iterator { // nothing new diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentComparison.java b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentComparison.java index 1b35c426..ba8c59a1 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentComparison.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentComparison.java @@ -1,5 +1,9 @@ package pl.poznan.put.matching; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import lombok.EqualsAndHashCode; import pl.poznan.put.circular.Angle; import pl.poznan.put.circular.ImmutableAngle; @@ -9,11 +13,6 @@ import pl.poznan.put.torsion.TorsionAngleDelta; import pl.poznan.put.torsion.range.RangeDifference; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - @EqualsAndHashCode public final class FragmentComparison implements Comparable { private final List residueComparisons; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentMatch.java b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentMatch.java index 75a7e977..dfe49f43 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentMatch.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentMatch.java @@ -1,5 +1,15 @@ package pl.poznan.put.matching; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import javax.swing.table.TableModel; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.time.DateFormatUtils; @@ -20,17 +30,6 @@ import pl.poznan.put.utility.NonEditableDefaultTableModel; import pl.poznan.put.utility.TabularExporter; -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - /** Holds information about a match between two {@link PdbCompactFragment}. */ @Data @Slf4j diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperimposer.java b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperimposer.java index cac32cb2..6f610536 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperimposer.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperimposer.java @@ -1,5 +1,13 @@ package pl.poznan.put.matching; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; +import javax.vecmath.Matrix4d; +import javax.vecmath.Point3d; import org.biojava.nbio.structure.geometry.CalcPoint; import org.biojava.nbio.structure.geometry.SuperPositions; import pl.poznan.put.atom.AtomName; @@ -17,15 +25,6 @@ import pl.poznan.put.rna.ImmutableRibose; import pl.poznan.put.rna.Nucleotide; -import javax.vecmath.Matrix4d; -import javax.vecmath.Point3d; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.List; -import java.util.Set; - public class FragmentSuperimposer { private final SelectionMatch selectionMatch; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperposition.java b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperposition.java index 00494c5e..6fa29d94 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperposition.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/FragmentSuperposition.java @@ -1,9 +1,8 @@ package pl.poznan.put.matching; -import pl.poznan.put.pdb.analysis.PdbCompactFragment; - import java.util.ArrayList; import java.util.List; +import pl.poznan.put.pdb.analysis.PdbCompactFragment; public class FragmentSuperposition { private final List targetFragments; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/HungarianAlgorithm.java b/mcq-core/src/main/java/pl/poznan/put/matching/HungarianAlgorithm.java index 66930598..83a1485f 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/HungarianAlgorithm.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/HungarianAlgorithm.java @@ -186,7 +186,9 @@ private void greedyMatch() { } } - /** @return the first unmatched worker or {@link #dim} if none. */ + /** + * @return the first unmatched worker or {@link #dim} if none. + */ private int fetchUnmatchedWorker() { int w; for (w = 0; w < dim; w++) { diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/MCQMatcher.java b/mcq-core/src/main/java/pl/poznan/put/matching/MCQMatcher.java index 8c23e80c..d392db1c 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/MCQMatcher.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/MCQMatcher.java @@ -1,5 +1,11 @@ package pl.poznan.put.matching; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import org.apache.commons.collections4.map.DefaultedMap; import org.apache.commons.lang3.tuple.Pair; import org.immutables.value.Value; @@ -11,13 +17,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.torsion.TorsionAngleDelta; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - @Value.Immutable public abstract class MCQMatcher implements StructureMatcher { private static List solveAssignmentProblem(final FragmentMatch[][] matrix) { diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/MatchCollectionDeltaIterator.java b/mcq-core/src/main/java/pl/poznan/put/matching/MatchCollectionDeltaIterator.java index 58ee9245..aee84dfa 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/MatchCollectionDeltaIterator.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/MatchCollectionDeltaIterator.java @@ -1,12 +1,11 @@ package pl.poznan.put.matching; -import org.apache.commons.collections4.IteratorUtils; -import pl.poznan.put.circular.Angle; -import pl.poznan.put.circular.samples.ImmutableAngleSample; - import java.util.Collection; import java.util.Iterator; import java.util.stream.Collectors; +import org.apache.commons.collections4.IteratorUtils; +import pl.poznan.put.circular.Angle; +import pl.poznan.put.circular.samples.ImmutableAngleSample; public class MatchCollectionDeltaIterator implements AngleDeltaIterator { private final Iterator iterator; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/ResidueComparison.java b/mcq-core/src/main/java/pl/poznan/put/matching/ResidueComparison.java index 42e47e4f..8029ca66 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/ResidueComparison.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/ResidueComparison.java @@ -1,5 +1,9 @@ package pl.poznan.put.matching; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import org.immutables.value.Value; import pl.poznan.put.circular.Angle; import pl.poznan.put.circular.samples.ImmutableAngleSample; @@ -12,11 +16,6 @@ import pl.poznan.put.torsion.TorsionAngleType; import pl.poznan.put.torsion.range.RangeDifference; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; - @Value.Immutable public abstract class ResidueComparison { public static ResidueComparison invalidInstance(final PdbResidue target, final PdbResidue model) { diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionFactory.java b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionFactory.java index d0e19db4..ff19ec2e 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionFactory.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionFactory.java @@ -1,16 +1,15 @@ package pl.poznan.put.matching; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; import pl.poznan.put.pdb.analysis.MoleculeType; import pl.poznan.put.pdb.analysis.PdbChain; import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.pdb.analysis.PdbModel; import pl.poznan.put.pdb.analysis.PdbResidue; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - public final class SelectionFactory { private SelectionFactory() { super(); diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionMatch.java b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionMatch.java index 9765fdb3..410a8f6d 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionMatch.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionMatch.java @@ -1,17 +1,16 @@ package pl.poznan.put.matching; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.time.DateFormatUtils; -import pl.poznan.put.interfaces.Exportable; - import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.time.DateFormatUtils; +import pl.poznan.put.interfaces.Exportable; @Data @NoArgsConstructor diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionQuery.java b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionQuery.java index 4c555eb5..509b3676 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/SelectionQuery.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/SelectionQuery.java @@ -1,5 +1,9 @@ package pl.poznan.put.matching; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.apache.commons.lang3.tuple.Pair; import pl.poznan.put.pdb.ImmutablePdbResidueIdentifier; import pl.poznan.put.pdb.PdbResidueIdentifier; @@ -9,11 +13,6 @@ import pl.poznan.put.pdb.analysis.PdbModel; import pl.poznan.put.pdb.analysis.PdbResidue; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - /** * Class which allow to parse a selection query of the following form CHAIN:NUMBER-ICODE:COUNT e.g. * A:1:5. Additionally, several selections can be supplied using plus operator like A:1:5+A:10:2 @@ -116,7 +115,8 @@ public List apply(final PdbModel model) { if (selectedResidues.size() != count) { throw new InvalidSelectionException( String.format( - "Failed to create selection starting at %s with %d residues. Was able to select only %d residues", + "Failed to create selection starting at %s with %d residues. Was able to select" + + " only %d residues", identifier, count, selectedResidues.size())); } diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/StructureSelection.java b/mcq-core/src/main/java/pl/poznan/put/matching/StructureSelection.java index a286e913..ece05ab3 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/StructureSelection.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/StructureSelection.java @@ -1,7 +1,23 @@ package pl.poznan.put.matching; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; import lombok.Data; import lombok.EqualsAndHashCode; +import org.apache.commons.lang3.StringUtils; import pl.poznan.put.circular.Angle; import pl.poznan.put.circular.ImmutableAngle; import pl.poznan.put.interfaces.Exportable; @@ -11,26 +27,16 @@ import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.pdb.analysis.PdbResidue; import pl.poznan.put.pdb.analysis.ResidueCollection; +import pl.poznan.put.pdb.analysis.ResidueInformationProvider; import pl.poznan.put.pdb.analysis.ResidueTorsionAngles; import pl.poznan.put.pdb.analysis.SingleTypedResidueCollection; +import pl.poznan.put.rna.NucleotideTorsionAngle; +import pl.poznan.put.torsion.AtomBasedTorsionAngleType; +import pl.poznan.put.torsion.AtomPair; import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.utility.AngleFormat; import pl.poznan.put.utility.TabularExporter; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - @Data @EqualsAndHashCode(onlyExplicitlyIncluded = true) public class StructureSelection implements Exportable, Tabular, ResidueCollection { @@ -215,4 +221,39 @@ private TableModel asTableModel(final boolean isDisplayable) { return new DefaultTableModel(data, columns.toArray(new String[0])); } + + @Override + public List findBondLengthViolations() { + final Set angleTypes = + residues().stream() + .map(PdbResidue::residueInformationProvider) + .map(ResidueInformationProvider::torsionAngleTypes) + .flatMap(Collection::stream) + .filter(torsionAngleType -> torsionAngleType instanceof AtomBasedTorsionAngleType) + .map(torsionAngleType -> (AtomBasedTorsionAngleType) torsionAngleType) + .filter(torsionAngleType -> !torsionAngleType.isPseudoTorsion()) + .filter( + torsionAngleType -> + !NucleotideTorsionAngle.CHI.angleTypes().contains(torsionAngleType)) + .collect(Collectors.toSet()); + + final Set atomPairs = new TreeSet<>(); + + for (final PdbCompactFragment fragment : compactFragments) { + atomPairs.addAll( + IntStream.range(0, fragment.residues().size()) + .boxed() + .flatMap( + i -> + angleTypes.stream() + .map(angleType -> angleType.findAtomPairs(fragment.residues(), i)) + .flatMap(Collection::stream)) + .collect(Collectors.toCollection(TreeSet::new))); + } + + return atomPairs.stream() + .map(AtomPair::generateValidationMessage) + .filter(StringUtils::isNotBlank) + .collect(Collectors.toList()); + } } diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/TypedDeltaIterator.java b/mcq-core/src/main/java/pl/poznan/put/matching/TypedDeltaIterator.java index e3b7a8a1..55672c3b 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/TypedDeltaIterator.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/TypedDeltaIterator.java @@ -1,10 +1,9 @@ package pl.poznan.put.matching; +import java.util.Iterator; import pl.poznan.put.circular.Angle; import pl.poznan.put.torsion.MasterTorsionAngleType; -import java.util.Iterator; - public class TypedDeltaIterator implements AngleDeltaIterator { private final Iterator iterator; private final MasterTorsionAngleType masterType; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/stats/MultiMatchStatistics.java b/mcq-core/src/main/java/pl/poznan/put/matching/stats/MultiMatchStatistics.java index a0ac486f..793d1340 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/stats/MultiMatchStatistics.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/stats/MultiMatchStatistics.java @@ -1,5 +1,9 @@ package pl.poznan.put.matching.stats; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import javax.swing.table.TableModel; import lombok.Data; import lombok.EqualsAndHashCode; import pl.poznan.put.matching.AngleDeltaIterator; @@ -10,11 +14,6 @@ import pl.poznan.put.utility.NonEditableDefaultTableModel; import pl.poznan.put.utility.NumberFormatUtils; -import javax.swing.table.TableModel; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - @Data public final class MultiMatchStatistics { private final List statistics; diff --git a/mcq-core/src/main/java/pl/poznan/put/matching/stats/SingleMatchStatistics.java b/mcq-core/src/main/java/pl/poznan/put/matching/stats/SingleMatchStatistics.java index 6af31388..c7ba651e 100644 --- a/mcq-core/src/main/java/pl/poznan/put/matching/stats/SingleMatchStatistics.java +++ b/mcq-core/src/main/java/pl/poznan/put/matching/stats/SingleMatchStatistics.java @@ -1,12 +1,11 @@ package pl.poznan.put.matching.stats; -import org.apache.commons.math3.stat.StatUtils; -import pl.poznan.put.circular.Angle; -import pl.poznan.put.matching.AngleDeltaIterator; - import java.util.ArrayList; import java.util.Collection; import java.util.Set; +import org.apache.commons.math3.stat.StatUtils; +import pl.poznan.put.circular.Angle; +import pl.poznan.put.matching.AngleDeltaIterator; public final class SingleMatchStatistics { static final double[] DEFAULT_PERCENTS_LIMITS = {95.0, 75.0, 50.0, 25.0}; diff --git a/mcq-core/src/main/java/pl/poznan/put/structure/StructureInfo.java b/mcq-core/src/main/java/pl/poznan/put/structure/StructureInfo.java index ed11836a..6024f719 100644 --- a/mcq-core/src/main/java/pl/poznan/put/structure/StructureInfo.java +++ b/mcq-core/src/main/java/pl/poznan/put/structure/StructureInfo.java @@ -1,10 +1,9 @@ package pl.poznan.put.structure; -import org.immutables.value.Value; -import pl.poznan.put.pdb.analysis.PdbModel; - import java.io.File; import java.util.Comparator; +import org.immutables.value.Value; +import pl.poznan.put.pdb.analysis.PdbModel; @Value.Immutable public abstract class StructureInfo implements Comparable { diff --git a/mcq-core/src/main/java/pl/poznan/put/structure/StructureManager.java b/mcq-core/src/main/java/pl/poznan/put/structure/StructureManager.java index 760a2e48..c85c55b2 100644 --- a/mcq-core/src/main/java/pl/poznan/put/structure/StructureManager.java +++ b/mcq-core/src/main/java/pl/poznan/put/structure/StructureManager.java @@ -1,12 +1,5 @@ package pl.poznan.put.structure; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import pl.poznan.put.pdb.analysis.CifParser; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.pdb.analysis.PdbParser; - import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; @@ -21,6 +14,12 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.zip.GZIPInputStream; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import pl.poznan.put.pdb.analysis.CifParser; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.pdb.analysis.PdbParser; /** * A common manager of loaded PDB files shared between all classes. diff --git a/mcq-core/src/main/java/pl/poznan/put/svg/ColoredNamedPoint.java b/mcq-core/src/main/java/pl/poznan/put/svg/ColoredNamedPoint.java index 3e245482..14ee48e7 100644 --- a/mcq-core/src/main/java/pl/poznan/put/svg/ColoredNamedPoint.java +++ b/mcq-core/src/main/java/pl/poznan/put/svg/ColoredNamedPoint.java @@ -1,12 +1,11 @@ package pl.poznan.put.svg; -import lombok.Data; -import lombok.EqualsAndHashCode; -import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; - import java.awt.*; import java.util.HashSet; import java.util.Set; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; @Data @EqualsAndHashCode(callSuper = true) diff --git a/mcq-core/src/main/java/pl/poznan/put/svg/MDSDrawer.java b/mcq-core/src/main/java/pl/poznan/put/svg/MDSDrawer.java index 19655f0c..a1d4bde7 100644 --- a/mcq-core/src/main/java/pl/poznan/put/svg/MDSDrawer.java +++ b/mcq-core/src/main/java/pl/poznan/put/svg/MDSDrawer.java @@ -1,18 +1,5 @@ package pl.poznan.put.svg; -import org.apache.batik.svggen.SVGGraphics2D; -import org.apache.batik.util.SVGConstants; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.math3.geometry.euclidean.twod.Segment; -import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; -import org.apache.commons.math3.geometry.euclidean.twod.hull.ConvexHull2D; -import org.apache.commons.math3.geometry.euclidean.twod.hull.ConvexHullGenerator2D; -import org.apache.commons.math3.geometry.euclidean.twod.hull.MonotoneChain; -import org.w3c.dom.svg.SVGDocument; -import org.w3c.dom.svg.SVGSVGElement; -import pl.poznan.put.types.DistanceMatrix; -import pl.poznan.put.utility.svg.SVGHelper; - import java.awt.Color; import java.awt.Font; import java.awt.font.LineMetrics; @@ -26,6 +13,18 @@ import java.util.Locale; import java.util.Map; import java.util.stream.Collectors; +import org.apache.batik.svggen.SVGGraphics2D; +import org.apache.batik.util.SVGConstants; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.math3.geometry.euclidean.twod.Segment; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; +import org.apache.commons.math3.geometry.euclidean.twod.hull.ConvexHull2D; +import org.apache.commons.math3.geometry.euclidean.twod.hull.ConvexHullGenerator2D; +import org.apache.commons.math3.geometry.euclidean.twod.hull.MonotoneChain; +import org.w3c.dom.svg.SVGDocument; +import org.w3c.dom.svg.SVGSVGElement; +import pl.poznan.put.types.DistanceMatrix; +import pl.poznan.put.utility.svg.SVGHelper; public final class MDSDrawer { private static final int DESIRED_WIDTH = 320; diff --git a/mcq-core/src/main/java/pl/poznan/put/svg/SecondaryStructureVisualizer.java b/mcq-core/src/main/java/pl/poznan/put/svg/SecondaryStructureVisualizer.java index 347262ce..74eb7ddd 100644 --- a/mcq-core/src/main/java/pl/poznan/put/svg/SecondaryStructureVisualizer.java +++ b/mcq-core/src/main/java/pl/poznan/put/svg/SecondaryStructureVisualizer.java @@ -9,6 +9,16 @@ import fr.orsay.lri.varna.models.rna.ModeleBase; import fr.orsay.lri.varna.models.rna.ModeleColorMap; import fr.orsay.lri.varna.models.rna.RNA; +import java.awt.Color; +import java.awt.geom.Rectangle2D; +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; import org.apache.batik.util.SVGConstants; import org.apache.commons.io.FileUtils; import org.jcolorbrewer.ColorBrewer; @@ -24,17 +34,6 @@ import pl.poznan.put.utility.ResourcesHelper; import pl.poznan.put.utility.svg.SVGHelper; -import java.awt.Color; -import java.awt.geom.Rectangle2D; -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; - public final class SecondaryStructureVisualizer { private static final Logger LOGGER = LoggerFactory.getLogger(SecondaryStructureVisualizer.class); diff --git a/mcq-core/src/test/java/pl/poznan/put/ComparisonTest.java b/mcq-core/src/test/java/pl/poznan/put/ComparisonTest.java index c3e35c97..6d239b1f 100644 --- a/mcq-core/src/test/java/pl/poznan/put/ComparisonTest.java +++ b/mcq-core/src/test/java/pl/poznan/put/ComparisonTest.java @@ -1,5 +1,9 @@ package pl.poznan.put; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; import org.junit.Assert; import org.junit.Test; import pl.poznan.put.comparison.ImmutableMCQ; @@ -20,11 +24,6 @@ import pl.poznan.put.pdb.analysis.PdbParser; import pl.poznan.put.utility.ResourcesHelper; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - public class ComparisonTest { private static final double[] LOCAL_MCQ_1EHZ_1EVV_DEGREES = { 35.4680665178865, diff --git a/mcq-core/src/test/java/pl/poznan/put/SelectionTest.java b/mcq-core/src/test/java/pl/poznan/put/SelectionTest.java index 0656e8df..4168c037 100644 --- a/mcq-core/src/test/java/pl/poznan/put/SelectionTest.java +++ b/mcq-core/src/test/java/pl/poznan/put/SelectionTest.java @@ -1,10 +1,14 @@ package pl.poznan.put; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; import org.junit.Test; import pl.poznan.put.matching.SelectionFactory; import pl.poznan.put.matching.SelectionQuery; import pl.poznan.put.matching.StructureSelection; -import pl.poznan.put.pdb.ImmutablePdbResidueIdentifier; import pl.poznan.put.pdb.analysis.PdbChain; import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.pdb.analysis.PdbModel; @@ -12,12 +16,6 @@ import pl.poznan.put.pdb.analysis.PdbResidue; import pl.poznan.put.utility.ResourcesHelper; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.hamcrest.MatcherAssert.assertThat; - public class SelectionTest { private final PdbParser parser = new PdbParser(); @@ -41,15 +39,18 @@ public final void testResidueBonds_74_77A_76() throws Exception { assertThat(compactFragments.size(), is(1)); // TODO: this test no longer works with the latest BioCommons -// final PdbCompactFragment compactFragment = compactFragments.get(0); -// final List residues = compactFragment.residues(); -// final int size = residues.size(); -// assertThat( -// residues.get(size - 3).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 74, " "))); -// assertThat( -// residues.get(size - 2).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 77, "A"))); -// assertThat( -// residues.get(size - 1).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 76, " "))); + // final PdbCompactFragment compactFragment = compactFragments.get(0); + // final List residues = compactFragment.residues(); + // final int size = residues.size(); + // assertThat( + // residues.get(size - 3).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 74, " + // "))); + // assertThat( + // residues.get(size - 2).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 77, + // "A"))); + // assertThat( + // residues.get(size - 1).identifier(), is(ImmutablePdbResidueIdentifier.of("B", 76, " + // "))); } @Test diff --git a/mcq-core/src/test/java/pl/poznan/put/TorsionTest.java b/mcq-core/src/test/java/pl/poznan/put/TorsionTest.java index 16689af1..c1673789 100644 --- a/mcq-core/src/test/java/pl/poznan/put/TorsionTest.java +++ b/mcq-core/src/test/java/pl/poznan/put/TorsionTest.java @@ -1,5 +1,9 @@ package pl.poznan.put; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.List; import org.junit.Assert; import org.junit.Test; import pl.poznan.put.circular.Angle; @@ -13,11 +17,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.utility.ResourcesHelper; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; - public class TorsionTest { // @formatter:off private static final MasterTorsionAngleType[] ANGLE_TYPES_FRABASE_ORDER = { diff --git a/mcq-core/src/test/java/pl/poznan/put/structure/StructureManagerTest.java b/mcq-core/src/test/java/pl/poznan/put/structure/StructureManagerTest.java index 4ba1a534..5ffca14e 100644 --- a/mcq-core/src/test/java/pl/poznan/put/structure/StructureManagerTest.java +++ b/mcq-core/src/test/java/pl/poznan/put/structure/StructureManagerTest.java @@ -1,5 +1,14 @@ package pl.poznan.put.structure; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.mockito.Mockito.mock; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.List; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FileUtils; import org.junit.After; @@ -9,16 +18,6 @@ import pl.poznan.put.pdb.analysis.PdbModel; import pl.poznan.put.utility.ResourcesHelper; -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.mockito.Mockito.mock; - public class StructureManagerTest { private File file1EHZ; private File file1EVV; @@ -39,7 +38,8 @@ public final void setUp() throws URISyntaxException, IOException { model1EVV = models1EVV.get(0); file1EVV = StructureManager.getFile(model1EVV); - final List models100D = StructureManager.loadStructure(ResourcesHelper.loadResourceFile("100D.cif")); + final List models100D = + StructureManager.loadStructure(ResourcesHelper.loadResourceFile("100D.cif")); assertThat(models100D.size(), is(1)); model100D = models100D.get(0); file100D = StructureManager.getFile(model100D); @@ -120,14 +120,16 @@ public final void getNameMultiModel() throws Exception { public final void getAllStructures() { final List structures = StructureManager.getAllStructures(); assertThat( - CollectionUtils.isEqualCollection(Arrays.asList(model1EHZ, model1EVV, model100D), structures), + CollectionUtils.isEqualCollection( + Arrays.asList(model1EHZ, model1EVV, model100D), structures), is(true)); } @Test public final void getAllNames() { final List names = StructureManager.getAllNames(); - assertThat(CollectionUtils.isEqualCollection(Arrays.asList("1EHZ", "1EVV", "100D"), names), is(true)); + assertThat( + CollectionUtils.isEqualCollection(Arrays.asList("1EHZ", "1EVV", "100D"), names), is(true)); } @Test diff --git a/mcq-gui/pom.xml b/mcq-gui/pom.xml index 4874ecc4..8e2543af 100644 --- a/mcq-gui/pom.xml +++ b/mcq-gui/pom.xml @@ -5,7 +5,7 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 mcq-gui @@ -16,6 +16,11 @@ logback-classic + + com.github.tzok + varna-tz + + commons-io commons-io @@ -73,11 +78,6 @@ ${project.version} - - com.github.tzok - varna-tz - - org.projectlombok lombok @@ -87,6 +87,11 @@ + + com.diffplug.spotless + spotless-maven-plugin + + com.github.ekryd.sortpom sortpom-maven-plugin diff --git a/mcq-gui/src/main/java/pl/poznan/put/datamodel/ProcessingResult.java b/mcq-gui/src/main/java/pl/poznan/put/datamodel/ProcessingResult.java index ff8e146a..377269d1 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/datamodel/ProcessingResult.java +++ b/mcq-gui/src/main/java/pl/poznan/put/datamodel/ProcessingResult.java @@ -1,15 +1,14 @@ package pl.poznan.put.datamodel; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; import org.w3c.dom.svg.SVGDocument; import pl.poznan.put.interfaces.Clusterable; import pl.poznan.put.interfaces.Exportable; import pl.poznan.put.interfaces.Visualizable; import pl.poznan.put.types.DistanceMatrix; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; - public class ProcessingResult implements Clusterable, Visualizable, Exportable { private final Object object; diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/component/FilteredListModel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/component/FilteredListModel.java index e700eadd..f7dcfca0 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/component/FilteredListModel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/component/FilteredListModel.java @@ -1,13 +1,12 @@ package pl.poznan.put.gui.component; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.pdb.analysis.PdbCompactFragment; - -import javax.swing.AbstractListModel; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.swing.AbstractListModel; +import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.pdb.analysis.PdbCompactFragment; public class FilteredListModel extends AbstractListModel { private static final long serialVersionUID = 2878196330323395518L; diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/component/PdbChooser.java b/mcq-gui/src/main/java/pl/poznan/put/gui/component/PdbChooser.java index 8cb60b03..1d711af2 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/component/PdbChooser.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/component/PdbChooser.java @@ -1,12 +1,12 @@ package pl.poznan.put.gui.component; -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.io.File; import java.util.Arrays; import java.util.Collections; import java.util.List; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; public final class PdbChooser extends JFileChooser { private static final PdbChooser INSTANCE = new PdbChooser(); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/component/SVGComponent.java b/mcq-gui/src/main/java/pl/poznan/put/gui/component/SVGComponent.java index 545048d5..dee71d48 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/component/SVGComponent.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/component/SVGComponent.java @@ -1,14 +1,5 @@ package pl.poznan.put.gui.component; -import org.apache.batik.swing.JSVGCanvas; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.svg.SVGDocument; -import pl.poznan.put.utility.svg.Format; -import pl.poznan.put.utility.svg.SVGHelper; - -import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -16,6 +7,14 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import javax.swing.*; +import org.apache.batik.swing.JSVGCanvas; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.svg.SVGDocument; +import pl.poznan.put.utility.svg.Format; +import pl.poznan.put.utility.svg.SVGHelper; public class SVGComponent extends JSVGCanvas { private static final Logger LOGGER = LoggerFactory.getLogger(SVGComponent.class); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenCheckBoxMenuItem.java b/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenCheckBoxMenuItem.java index dd8a99b7..4307e697 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenCheckBoxMenuItem.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenCheckBoxMenuItem.java @@ -11,7 +11,9 @@ public class StayOpenCheckBoxMenuItem extends JCheckBoxMenuItem { private static final long serialVersionUID = 1L; private MenuElement[] path; - /** @see JCheckBoxMenuItem#JCheckBoxMenuItem(String, boolean) */ + /** + * @see JCheckBoxMenuItem#JCheckBoxMenuItem(String, boolean) + */ public StayOpenCheckBoxMenuItem(final String text, final boolean selected) { super(text, selected); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenRadioButtonMenuItem.java b/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenRadioButtonMenuItem.java index 52812991..c350a639 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenRadioButtonMenuItem.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/component/StayOpenRadioButtonMenuItem.java @@ -11,7 +11,9 @@ public class StayOpenRadioButtonMenuItem extends JRadioButtonMenuItem { private static final long serialVersionUID = 1L; private MenuElement[] path; - /** @see JRadioButtonMenuItem#JRadioButtonMenuItem(String, boolean) */ + /** + * @see JRadioButtonMenuItem#JRadioButtonMenuItem(String, boolean) + */ public StayOpenRadioButtonMenuItem(final String text, final boolean selected) { super(text, selected); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/ChainsPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/ChainsPanel.java index 9c81f86c..74bfe190 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/ChainsPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/ChainsPanel.java @@ -1,10 +1,11 @@ package pl.poznan.put.gui.panel; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.pdb.analysis.PdbChain; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.structure.StructureManager; - +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.GridLayout; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -15,12 +16,10 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListCellRenderer; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; +import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.pdb.analysis.PdbChain; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.structure.StructureManager; public class ChainsPanel extends JPanel { private final DefaultComboBoxModel structureComboBoxModel = diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/GlobalMatrixPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/GlobalMatrixPanel.java index af3cd1d9..aafa031e 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/GlobalMatrixPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/GlobalMatrixPanel.java @@ -1,5 +1,13 @@ package pl.poznan.put.gui.panel; +import java.awt.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; import lombok.extern.slf4j.Slf4j; import org.w3c.dom.svg.SVGDocument; import pl.poznan.put.circular.exception.InvalidCircularValueException; @@ -15,15 +23,6 @@ import pl.poznan.put.utility.svg.SVGHelper; import pl.poznan.put.visualisation.VisualizableGlobalMatrix; -import javax.swing.*; -import javax.swing.border.EmptyBorder; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellRenderer; -import java.awt.*; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - @Slf4j public final class GlobalMatrixPanel extends JPanel { private static final long serialVersionUID = 4604714903697643882L; diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMatrixPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMatrixPanel.java index 964fef4e..98650f14 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMatrixPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMatrixPanel.java @@ -1,5 +1,19 @@ package pl.poznan.put.gui.panel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,21 +38,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.visualisation.VisualizableFragmentMatch; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableCellRenderer; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.util.List; - public final class LocalMatrixPanel extends JPanel { private static final long serialVersionUID = -1143002202021225397L; private static final Logger LOGGER = LoggerFactory.getLogger(LocalMatrixPanel.class); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMultiMatrixPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMultiMatrixPanel.java index ea94c945..9d4b493e 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMultiMatrixPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/LocalMultiMatrixPanel.java @@ -1,5 +1,21 @@ package pl.poznan.put.gui.panel; +import java.awt.BorderLayout; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.svg.SVGDocument; @@ -20,23 +36,6 @@ import pl.poznan.put.utility.svg.SVGHelper; import pl.poznan.put.visualisation.VisualizableSelectedAngle; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.TableModel; -import java.awt.BorderLayout; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - public final class LocalMultiMatrixPanel extends JPanel { private static final long serialVersionUID = 1743569049211593671L; private static final Logger LOGGER = LoggerFactory.getLogger(LocalMultiMatrixPanel.class); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleTypesPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleTypesPanel.java index 80031b9e..12208509 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleTypesPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleTypesPanel.java @@ -1,17 +1,5 @@ package pl.poznan.put.gui.panel; -import pl.poznan.put.interfaces.DisplayableExportable; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.torsion.AverageTorsionAngleType; -import pl.poznan.put.torsion.MasterTorsionAngleType; - -import javax.swing.AbstractButton; -import javax.swing.BorderFactory; -import javax.swing.BoxLayout; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -21,6 +9,17 @@ import java.util.Map; import java.util.TreeSet; import java.util.stream.Collectors; +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import pl.poznan.put.interfaces.DisplayableExportable; +import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.torsion.AverageTorsionAngleType; +import pl.poznan.put.torsion.MasterTorsionAngleType; public class TorsionAngleTypesPanel extends JPanel { private final Map mapCheckBoxToMasterType = diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleValuesMatrixPanel.java b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleValuesMatrixPanel.java index 7d181535..033854e6 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleValuesMatrixPanel.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/panel/TorsionAngleValuesMatrixPanel.java @@ -1,5 +1,14 @@ package pl.poznan.put.gui.panel; +import java.awt.BorderLayout; +import java.util.List; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.UIManager; +import javax.swing.border.EmptyBorder; import lombok.extern.slf4j.Slf4j; import org.w3c.dom.svg.SVGDocument; import pl.poznan.put.circular.Angle; @@ -14,16 +23,6 @@ import pl.poznan.put.torsion.MasterTorsionAngleType; import pl.poznan.put.visualisation.AngularHistogram; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; -import javax.swing.JTable; -import javax.swing.JTextPane; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import java.awt.BorderLayout; -import java.util.List; - @Slf4j public final class TorsionAngleValuesMatrixPanel extends JPanel { private static final long serialVersionUID = -59286774381464603L; @@ -91,7 +90,8 @@ private void removeAllButFirstTab() { private void updateHeader(final PdbModel structure) { labelInfoMatrix.setText( String.format( - "Structure selected for torsion angles calculation: %s", + "Structure selected for torsion angles calculation: %s", StructureManager.getName(structure))); } } diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogAbout.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogAbout.java index e8310c3f..4c8e92c4 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogAbout.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogAbout.java @@ -1,18 +1,17 @@ package pl.poznan.put.gui.window; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.imageio.ImageIO; -import javax.swing.*; -import javax.swing.event.HyperlinkEvent; import java.awt.*; import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.StandardCharsets; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.event.HyperlinkEvent; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class DialogAbout extends JDialog { private static final Logger LOGGER = LoggerFactory.getLogger(DialogAbout.class); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogCluster.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogCluster.java index fd2ed17f..3e8b5939 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogCluster.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogCluster.java @@ -1,5 +1,20 @@ package pl.poznan.put.gui.window; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Toolkit; +import java.awt.event.ActionListener; +import java.util.List; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JRadioButton; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; import org.w3c.dom.svg.SVGDocument; import pl.poznan.put.clustering.hierarchical.Clusterer; import pl.poznan.put.clustering.hierarchical.Linkage; @@ -14,22 +29,6 @@ import pl.poznan.put.interfaces.Visualizable; import pl.poznan.put.types.DistanceMatrix; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JDialog; -import javax.swing.JRadioButton; -import javax.swing.JSpinner; -import javax.swing.SpinnerNumberModel; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Toolkit; -import java.awt.event.ActionListener; -import java.util.List; - public class DialogCluster extends JDialog { private static final long serialVersionUID = -4544656737734548208L; diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogGuide.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogGuide.java index dde84ece..4cba9427 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogGuide.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogGuide.java @@ -1,10 +1,5 @@ package pl.poznan.put.gui.window; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -12,6 +7,10 @@ import java.io.InputStream; import java.net.URL; import java.nio.charset.StandardCharsets; +import javax.swing.*; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @SuppressWarnings("ALL") public class DialogGuide extends JDialog { diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogManager.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogManager.java index e2ed7f64..a746c151 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogManager.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogManager.java @@ -1,12 +1,13 @@ package pl.poznan.put.gui.window; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import pl.poznan.put.gui.component.PdbChooser; -import pl.poznan.put.pdb.PdbParsingException; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.structure.StructureManager; - +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Toolkit; +import java.io.File; +import java.io.IOException; +import java.util.Enumeration; +import java.util.List; import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.JButton; @@ -17,14 +18,12 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.Frame; -import java.awt.Toolkit; -import java.io.File; -import java.io.IOException; -import java.util.Enumeration; -import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import pl.poznan.put.gui.component.PdbChooser; +import pl.poznan.put.pdb.PdbParsingException; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.structure.StructureManager; public final class DialogManager extends JDialog { private static final long serialVersionUID = 8406487603428842396L; diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectAngles.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectAngles.java index a26a532c..74479e45 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectAngles.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectAngles.java @@ -1,14 +1,13 @@ package pl.poznan.put.gui.window; -import pl.poznan.put.gui.panel.TorsionAngleTypesPanel; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.torsion.MasterTorsionAngleType; - -import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.swing.*; +import pl.poznan.put.gui.panel.TorsionAngleTypesPanel; +import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.torsion.MasterTorsionAngleType; final class DialogSelectAngles extends JDialog { private final List selectedAngles = new ArrayList<>(); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChains.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChains.java index 33126519..e8665aaf 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChains.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChains.java @@ -1,17 +1,16 @@ package pl.poznan.put.gui.window; -import org.apache.commons.lang3.tuple.Pair; -import pl.poznan.put.gui.panel.ChainsPanel; -import pl.poznan.put.pdb.analysis.PdbChain; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.structure.StructureManager; - -import javax.swing.*; import java.awt.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Stream; +import javax.swing.*; +import org.apache.commons.lang3.tuple.Pair; +import pl.poznan.put.gui.panel.ChainsPanel; +import pl.poznan.put.pdb.analysis.PdbChain; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.structure.StructureManager; final class DialogSelectChains extends JDialog { private static final Dimension INITIAL_MAIN_PANEL_SIZE = new Dimension(640, 480); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChainsMultiple.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChainsMultiple.java index a9aaab65..a174dc2d 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChainsMultiple.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectChainsMultiple.java @@ -1,25 +1,5 @@ package pl.poznan.put.gui.window; -import pl.poznan.put.gui.component.FilteredListModel; -import pl.poznan.put.matching.SelectionFactory; -import pl.poznan.put.matching.StructureSelection; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.pdb.analysis.PdbChain; -import pl.poznan.put.pdb.analysis.PdbCompactFragment; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.structure.StructureManager; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.ListCellRenderer; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionListener; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -32,6 +12,25 @@ import java.util.Collection; import java.util.Collections; import java.util.List; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListCellRenderer; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionListener; +import pl.poznan.put.gui.component.FilteredListModel; +import pl.poznan.put.matching.SelectionFactory; +import pl.poznan.put.matching.StructureSelection; +import pl.poznan.put.pdb.analysis.MoleculeType; +import pl.poznan.put.pdb.analysis.PdbChain; +import pl.poznan.put.pdb.analysis.PdbCompactFragment; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.structure.StructureManager; final class DialogSelectChainsMultiple extends JDialog { private final FilteredListModel modelAll = new FilteredListModel(); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectStructures.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectStructures.java index ce95119c..886e70fe 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectStructures.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/DialogSelectStructures.java @@ -1,16 +1,15 @@ package pl.poznan.put.gui.window; -import pl.poznan.put.pdb.analysis.PdbModel; -import pl.poznan.put.structure.StructureManager; - -import javax.swing.*; -import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; +import javax.swing.*; +import javax.swing.event.ListSelectionListener; +import pl.poznan.put.pdb.analysis.PdbModel; +import pl.poznan.put.structure.StructureManager; final class DialogSelectStructures extends JDialog { private static final Dimension INITIAL_STRUCTURE_LIST_SIZE = new Dimension(320, 420); diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/MainWindow.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/MainWindow.java index b6bd4c8e..1f68ce43 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/MainWindow.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/MainWindow.java @@ -1,5 +1,35 @@ package pl.poznan.put.gui.window; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.Toolkit; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.WindowConstants; import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.math3.util.FastMath; import pl.poznan.put.circular.Angle; @@ -22,485 +52,453 @@ import pl.poznan.put.structure.StructureManager; import pl.poznan.put.types.DistanceMatrix; -import javax.swing.ButtonGroup; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.SwingUtilities; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.WindowConstants; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Dimension; -import java.awt.Toolkit; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - public final class MainWindow extends JFrame { - private static final String CARD_TORSION = "CARD_TORSION"; - private static final String CARD_GLOBAL_MATRIX = "CARD_GLOBAL_MATRIX"; - private static final String CARD_LOCAL_MATRIX = "CARD_LOCAL_MATRIX"; - private static final String CARD_LOCAL_MULTI_MATRIX = "CARD_LOCAL_MULTI_MATRIX"; - private static final String TITLE = - "MCQ4Structures: computing similarity of 3D RNA / protein " + "structures"; - private final JMenu menuFile = new JMenu("File"); - private final JMenuItem itemOpen = new JMenuItem("Open structure(s)"); - private final JMenuItem itemSave = new JMenuItem("Save results"); - private final JCheckBoxMenuItem checkBoxManager = - new StayOpenCheckBoxMenuItem("View structure manager", false); - private final JMenuItem itemExit = new JMenuItem("Exit"); - private final JMenu menuTorsionAngles = new JMenu("Torsion angles"); - private final JMenuItem itemSelectStructureTorsionAngles = - new JMenuItem("Select structure to represent in torsion angle space"); - private final JMenu menuDistanceMeasure = new JMenu("Distance measure"); - private final JRadioButtonMenuItem radioGlobalMcq = - new StayOpenRadioButtonMenuItem("Global MCQ", true); - private final JRadioButtonMenuItem radioGlobalRmsd = - new StayOpenRadioButtonMenuItem("Global RMSD", false); - private final JRadioButtonMenuItem radioGlobalLcs = - new StayOpenRadioButtonMenuItem("Global LCS", false); - private final JRadioButtonMenuItem radioLocal = - new StayOpenRadioButtonMenuItem("Local distances (pair)", false); - private final JRadioButtonMenuItem radioLocalMulti = - new StayOpenRadioButtonMenuItem("Local distances (multiple)", false); - private final JMenuItem itemSelectStructuresCompare = - new JMenuItem("Select structures to compare"); - private final JMenuItem itemCluster = new JMenuItem("Cluster results"); - private final ActionListener radioActionListener = - arg0 -> itemCluster.setEnabled(false); - private final JMenu menuAlignment = new JMenu("Alignment"); - private final JRadioButtonMenuItem radioAlignSeqGlobal = - new StayOpenRadioButtonMenuItem("Global sequence alignment", true); - private final JRadioButtonMenuItem radioAlignSeqLocal = - new StayOpenRadioButtonMenuItem("Local sequence alignment", false); - private final JRadioButtonMenuItem radioAlignStruc = - new StayOpenRadioButtonMenuItem("3D structure alignment", false); - private final JMenu menuHelp = new JMenu("Help"); - private final JMenuItem itemGuide = new JMenuItem("Quick guide"); - private final JMenuItem itemAbout = new JMenuItem("About"); - private final CardLayout layoutCards = new CardLayout(); - private final JPanel panelCards = new JPanel(); - private final TorsionAngleValuesMatrixPanel panelTorsionAngles = - new TorsionAngleValuesMatrixPanel(); - private final GlobalMatrixPanel panelResultsGlobalMatrix = new GlobalMatrixPanel(); - private final LocalMatrixPanel panelResultsLocalMatrix = new LocalMatrixPanel(); - private final LocalMultiMatrixPanel panelResultsLocalMultiMatrix = new LocalMultiMatrixPanel(); - private final JFileChooser fileChooser = new JFileChooser(); - private final DialogManager dialogManager; - private final DialogSelectStructures dialogStructures; - private final DialogSelectChains dialogChains; - private final DialogSelectChainsMultiple dialogChainsMultiple; - private final DialogSelectAngles dialogAngles; - private ProcessingResult currentResult = ProcessingResult.emptyInstance(); - private final ActionListener selectActionListener = - e -> { - assert e != null; - final JMenuItem source = (JMenuItem) e.getSource(); - - if (source.equals(itemSelectStructureTorsionAngles)) { - selectSingleStructure(); - } else if (source.equals(itemSelectStructuresCompare)) { - if (radioLocal.isSelected()) { - selectChains(source); - } else if (radioLocalMulti.isSelected()) { - selectChainsMultiple(source); - } else { - selectStructures(); - } - } else { - if (radioAlignStruc.isSelected()) { - selectChains(source); - } else { - selectChainsMultiple(source); - } - } - }; - - private MainWindow(final Iterable pdbs) { - super(); - - dialogManager = new DialogManager(this); - dialogStructures = new DialogSelectStructures(this); - dialogChains = new DialogSelectChains(this); - dialogChainsMultiple = new DialogSelectChainsMultiple(this); - dialogAngles = new DialogSelectAngles(this); - - dialogManager.loadStructures(pdbs); - - createMenu(); - initializeMenu(); - registerMenuActionListeners(); - - panelCards.setLayout(layoutCards); - panelCards.add(new JPanel()); - panelCards.add(panelTorsionAngles, MainWindow.CARD_TORSION); - panelCards.add(panelResultsGlobalMatrix, MainWindow.CARD_GLOBAL_MATRIX); - panelCards.add(panelResultsLocalMatrix, MainWindow.CARD_LOCAL_MATRIX); - panelCards.add(panelResultsLocalMultiMatrix, MainWindow.CARD_LOCAL_MULTI_MATRIX); - - setLayout(new BorderLayout()); - add(panelCards, BorderLayout.CENTER); - - setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); - setTitle(MainWindow.TITLE); - - final Toolkit toolkit = Toolkit.getDefaultToolkit(); - final Dimension size = toolkit.getScreenSize(); - setSize(size.width * 3 / 4, size.height * 3 / 4); - setLocation(size.width / 8, size.height / 8); - - dialogManager.addWindowListener( - new WindowAdapter() { - @Override - public void windowClosing(final WindowEvent windowEvent) { - super.windowClosing(windowEvent); - checkBoxManager.setSelected(false); - } - }); - } + private static final String CARD_TORSION = "CARD_TORSION"; + private static final String CARD_GLOBAL_MATRIX = "CARD_GLOBAL_MATRIX"; + private static final String CARD_LOCAL_MATRIX = "CARD_LOCAL_MATRIX"; + private static final String CARD_LOCAL_MULTI_MATRIX = "CARD_LOCAL_MULTI_MATRIX"; + private static final String TITLE = + "MCQ4Structures: computing similarity of 3D RNA / protein " + "structures"; + private final JMenu menuFile = new JMenu("File"); + private final JMenuItem itemOpen = new JMenuItem("Open structure(s)"); + private final JMenuItem itemSave = new JMenuItem("Save results"); + private final JCheckBoxMenuItem checkBoxManager = + new StayOpenCheckBoxMenuItem("View structure manager", false); + private final JMenuItem itemExit = new JMenuItem("Exit"); + private final JMenu menuTorsionAngles = new JMenu("Torsion angles"); + private final JMenuItem itemSelectStructureTorsionAngles = + new JMenuItem("Select structure to represent in torsion angle space"); + private final JMenu menuDistanceMeasure = new JMenu("Distance measure"); + private final JRadioButtonMenuItem radioGlobalMcq = + new StayOpenRadioButtonMenuItem("Global MCQ", true); + private final JRadioButtonMenuItem radioGlobalRmsd = + new StayOpenRadioButtonMenuItem("Global RMSD", false); + private final JRadioButtonMenuItem radioGlobalLcs = + new StayOpenRadioButtonMenuItem("Global LCS", false); + private final JRadioButtonMenuItem radioLocal = + new StayOpenRadioButtonMenuItem("Local distances (pair)", false); + private final JRadioButtonMenuItem radioLocalMulti = + new StayOpenRadioButtonMenuItem("Local distances (multiple)", false); + private final JMenuItem itemSelectStructuresCompare = + new JMenuItem("Select structures to compare"); + private final JMenuItem itemCluster = new JMenuItem("Cluster results"); + private final ActionListener radioActionListener = arg0 -> itemCluster.setEnabled(false); + private final JMenu menuAlignment = new JMenu("Alignment"); + private final JRadioButtonMenuItem radioAlignSeqGlobal = + new StayOpenRadioButtonMenuItem("Global sequence alignment", true); + private final JRadioButtonMenuItem radioAlignSeqLocal = + new StayOpenRadioButtonMenuItem("Local sequence alignment", false); + private final JRadioButtonMenuItem radioAlignStruc = + new StayOpenRadioButtonMenuItem("3D structure alignment", false); + private final JMenu menuHelp = new JMenu("Help"); + private final JMenuItem itemGuide = new JMenuItem("Quick guide"); + private final JMenuItem itemAbout = new JMenuItem("About"); + private final CardLayout layoutCards = new CardLayout(); + private final JPanel panelCards = new JPanel(); + private final TorsionAngleValuesMatrixPanel panelTorsionAngles = + new TorsionAngleValuesMatrixPanel(); + private final GlobalMatrixPanel panelResultsGlobalMatrix = new GlobalMatrixPanel(); + private final LocalMatrixPanel panelResultsLocalMatrix = new LocalMatrixPanel(); + private final LocalMultiMatrixPanel panelResultsLocalMultiMatrix = new LocalMultiMatrixPanel(); + private final JFileChooser fileChooser = new JFileChooser(); + private final DialogManager dialogManager; + private final DialogSelectStructures dialogStructures; + private final DialogSelectChains dialogChains; + private final DialogSelectChainsMultiple dialogChainsMultiple; + private final DialogSelectAngles dialogAngles; + private ProcessingResult currentResult = ProcessingResult.emptyInstance(); + private final ActionListener selectActionListener = + e -> { + assert e != null; + final JMenuItem source = (JMenuItem) e.getSource(); + + if (source.equals(itemSelectStructureTorsionAngles)) { + selectSingleStructure(); + } else if (source.equals(itemSelectStructuresCompare)) { + if (radioLocal.isSelected()) { + selectChains(source); + } else if (radioLocalMulti.isSelected()) { + selectChainsMultiple(source); + } else { + selectStructures(); + } + } else { + if (radioAlignStruc.isSelected()) { + selectChains(source); + } else { + selectChainsMultiple(source); + } + } + }; + + private MainWindow(final Iterable pdbs) { + super(); + + dialogManager = new DialogManager(this); + dialogStructures = new DialogSelectStructures(this); + dialogChains = new DialogSelectChains(this); + dialogChainsMultiple = new DialogSelectChainsMultiple(this); + dialogAngles = new DialogSelectAngles(this); + + dialogManager.loadStructures(pdbs); + + createMenu(); + initializeMenu(); + registerMenuActionListeners(); + + panelCards.setLayout(layoutCards); + panelCards.add(new JPanel()); + panelCards.add(panelTorsionAngles, MainWindow.CARD_TORSION); + panelCards.add(panelResultsGlobalMatrix, MainWindow.CARD_GLOBAL_MATRIX); + panelCards.add(panelResultsLocalMatrix, MainWindow.CARD_LOCAL_MATRIX); + panelCards.add(panelResultsLocalMultiMatrix, MainWindow.CARD_LOCAL_MULTI_MATRIX); + + setLayout(new BorderLayout()); + add(panelCards, BorderLayout.CENTER); + + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + setTitle(MainWindow.TITLE); + + final Toolkit toolkit = Toolkit.getDefaultToolkit(); + final Dimension size = toolkit.getScreenSize(); + setSize(size.width * 3 / 4, size.height * 3 / 4); + setLocation(size.width / 8, size.height / 8); + + dialogManager.addWindowListener( + new WindowAdapter() { + @Override + public void windowClosing(final WindowEvent windowEvent) { + super.windowClosing(windowEvent); + checkBoxManager.setSelected(false); + } + }); + } + + public static void main(final String[] args) { + final List pdbs = + Arrays.stream(args).map(File::new).filter(File::canRead).collect(Collectors.toList()); + + SwingUtilities.invokeLater( + () -> { + /* + * Set L&F + */ + for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + try { + UIManager.setLookAndFeel(info.getClassName()); + } catch (final ClassNotFoundException + | InstantiationException + | IllegalAccessException + | UnsupportedLookAndFeelException e) { + // do nothing + } + break; + } + } + + final MainWindow window = new MainWindow(pdbs); + window.setVisible(true); + }); + } + + private void createMenu() { + final JMenuBar menuBar = new JMenuBar(); + + menuFile.setMnemonic(KeyEvent.VK_F); + menuFile.add(itemOpen); + menuFile.add(itemSave); + menuFile.addSeparator(); + menuFile.add(checkBoxManager); + menuFile.addSeparator(); + menuFile.add(itemExit); + menuBar.add(menuFile); + + menuTorsionAngles.setMnemonic(KeyEvent.VK_T); + menuTorsionAngles.add(itemSelectStructureTorsionAngles); + menuBar.add(menuTorsionAngles); + + menuDistanceMeasure.setMnemonic(KeyEvent.VK_D); + menuDistanceMeasure.add(new JLabel(" Select distance type:")); + menuDistanceMeasure.add(radioGlobalMcq); + menuDistanceMeasure.add(radioGlobalRmsd); + menuDistanceMeasure.add(radioGlobalLcs); + menuDistanceMeasure.add(radioLocal); + menuDistanceMeasure.add(radioLocalMulti); + menuDistanceMeasure.addSeparator(); + menuDistanceMeasure.add(itemSelectStructuresCompare); + menuDistanceMeasure.addSeparator(); + menuDistanceMeasure.add(itemCluster); + menuBar.add(menuDistanceMeasure); + + menuAlignment.setMnemonic(KeyEvent.VK_A); + menuAlignment.add(new JLabel(" Select alignment type:")); + menuAlignment.add(radioAlignSeqGlobal); + menuAlignment.add(radioAlignSeqLocal); + menuAlignment.add(radioAlignStruc); + menuAlignment.addSeparator(); + menuBar.add(menuAlignment); + + menuHelp.setMnemonic(KeyEvent.VK_H); + menuHelp.add(itemGuide); + menuHelp.add(itemAbout); + menuBar.add(menuHelp); + + setJMenuBar(menuBar); + } + + private void initializeMenu() { + itemSave.setEnabled(false); + itemCluster.setEnabled(false); + + final ButtonGroup group = new ButtonGroup(); + group.add(radioGlobalMcq); + group.add(radioGlobalRmsd); + group.add(radioGlobalLcs); + group.add(radioLocal); + group.add(radioLocalMulti); + + final ButtonGroup groupAlign = new ButtonGroup(); + groupAlign.add(radioAlignSeqGlobal); + groupAlign.add(radioAlignSeqLocal); + groupAlign.add(radioAlignStruc); + } + + private void registerMenuActionListeners() { + radioGlobalMcq.addActionListener(radioActionListener); + radioGlobalRmsd.addActionListener(radioActionListener); + radioGlobalLcs.addActionListener(radioActionListener); + radioLocal.addActionListener(radioActionListener); + radioLocalMulti.addActionListener(radioActionListener); + + itemSelectStructureTorsionAngles.addActionListener(selectActionListener); + itemSelectStructuresCompare.addActionListener(selectActionListener); + + radioAlignSeqGlobal.addActionListener(radioActionListener); + + itemOpen.addActionListener(e -> dialogManager.selectAndLoadStructures()); + + itemSave.addActionListener(e -> saveResults()); + + checkBoxManager.addActionListener(e -> dialogManager.setVisible(checkBoxManager.isSelected())); + + itemExit.addActionListener( + e -> dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING))); + + itemCluster.addActionListener( + arg0 -> { + if (currentResult.canCluster()) { + final DistanceMatrix distanceMatrix = currentResult.distanceMatrix(); + final double[][] array = distanceMatrix.matrix(); + + if (array.length <= 1) { + final String message = + "Cannot cluster this distance matrix, because" + + " it contains zero valid comparisons"; + JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE); + return; + } - public static void main(final String[] args) { - final List pdbs = - Arrays.stream(args).map(File::new).filter(File::canRead).collect(Collectors.toList()); - - SwingUtilities.invokeLater( - () -> { - /* - * Set L&F - */ - for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - try { - UIManager.setLookAndFeel(info.getClassName()); - } catch (final ClassNotFoundException - | InstantiationException - | IllegalAccessException - | UnsupportedLookAndFeelException e) { - // do nothing - } - break; - } - } - - final MainWindow window = new MainWindow(pdbs); - window.setVisible(true); - }); + final DialogCluster dialogClustering = new DialogCluster(distanceMatrix); + dialogClustering.setVisible(true); + } + }); + + itemGuide.addActionListener( + e -> { + final DialogGuide dialog = new DialogGuide(this); + dialog.setVisible(true); + }); + + itemAbout.addActionListener( + e -> { + final DialogAbout dialog = new DialogAbout(this); + dialog.setVisible(true); + }); + } + + private void saveResults() { + if (currentResult.canExport()) { + final File suggestedName = currentResult.suggestName(); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setSelectedFile(suggestedName); + + if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { + try (final OutputStream stream = new FileOutputStream(fileChooser.getSelectedFile())) { + currentResult.export(stream); + JOptionPane.showMessageDialog( + this, + "Successfully exported the " + "results!", + "Information", + JOptionPane.INFORMATION_MESSAGE); + } catch (final IOException e) { + JOptionPane.showMessageDialog( + this, + "Failed to export the " + "results, reason: " + e.getMessage(), + "Error", + JOptionPane.ERROR_MESSAGE); + } + } } - - private void createMenu() { - final JMenuBar menuBar = new JMenuBar(); - - menuFile.setMnemonic(KeyEvent.VK_F); - menuFile.add(itemOpen); - menuFile.add(itemSave); - menuFile.addSeparator(); - menuFile.add(checkBoxManager); - menuFile.addSeparator(); - menuFile.add(itemExit); - menuBar.add(menuFile); - - menuTorsionAngles.setMnemonic(KeyEvent.VK_T); - menuTorsionAngles.add(itemSelectStructureTorsionAngles); - menuBar.add(menuTorsionAngles); - - menuDistanceMeasure.setMnemonic(KeyEvent.VK_D); - menuDistanceMeasure.add(new JLabel(" Select distance type:")); - menuDistanceMeasure.add(radioGlobalMcq); - menuDistanceMeasure.add(radioGlobalRmsd); - menuDistanceMeasure.add(radioGlobalLcs); - menuDistanceMeasure.add(radioLocal); - menuDistanceMeasure.add(radioLocalMulti); - menuDistanceMeasure.addSeparator(); - menuDistanceMeasure.add(itemSelectStructuresCompare); - menuDistanceMeasure.addSeparator(); - menuDistanceMeasure.add(itemCluster); - menuBar.add(menuDistanceMeasure); - - menuAlignment.setMnemonic(KeyEvent.VK_A); - menuAlignment.add(new JLabel(" Select alignment type:")); - menuAlignment.add(radioAlignSeqGlobal); - menuAlignment.add(radioAlignSeqLocal); - menuAlignment.add(radioAlignStruc); - menuAlignment.addSeparator(); - menuBar.add(menuAlignment); - - menuHelp.setMnemonic(KeyEvent.VK_H); - menuHelp.add(itemGuide); - menuHelp.add(itemAbout); - menuBar.add(menuHelp); - - setJMenuBar(menuBar); + } + + private void selectSingleStructure() { + itemSave.setEnabled(false); + + final List names = StructureManager.getAllNames(); + final String[] selectionValues = names.toArray(new String[0]); + final String name = + (String) + JOptionPane.showInputDialog( + this, + "Select structure", + "Represent structure in torsion angle space", + JOptionPane.QUESTION_MESSAGE, + null, + selectionValues, + null); + + if (name != null) { + final PdbModel structure = StructureManager.getStructure(name); + currentResult = panelTorsionAngles.calculateTorsionAngles(structure); + layoutCards.show(panelCards, MainWindow.CARD_TORSION); + updateMenuEnabledStates(); } + } - private void initializeMenu() { - itemSave.setEnabled(false); - itemCluster.setEnabled(false); - - final ButtonGroup group = new ButtonGroup(); - group.add(radioGlobalMcq); - group.add(radioGlobalRmsd); - group.add(radioGlobalLcs); - group.add(radioLocal); - group.add(radioLocalMulti); - - final ButtonGroup groupAlign = new ButtonGroup(); - groupAlign.add(radioAlignSeqGlobal); - groupAlign.add(radioAlignSeqLocal); - groupAlign.add(radioAlignStruc); - } + private void updateMenuEnabledStates() { + itemSave.setEnabled(currentResult.canExport()); + itemCluster.setEnabled(currentResult.canCluster()); - private void registerMenuActionListeners() { - radioGlobalMcq.addActionListener(radioActionListener); - radioGlobalRmsd.addActionListener(radioActionListener); - radioGlobalLcs.addActionListener(radioActionListener); - radioLocal.addActionListener(radioActionListener); - radioLocalMulti.addActionListener(radioActionListener); - - itemSelectStructureTorsionAngles.addActionListener(selectActionListener); - itemSelectStructuresCompare.addActionListener(selectActionListener); - - radioAlignSeqGlobal.addActionListener(radioActionListener); - - itemOpen.addActionListener(e -> dialogManager.selectAndLoadStructures()); - - itemSave.addActionListener(e -> saveResults()); - - checkBoxManager.addActionListener(e -> dialogManager.setVisible(checkBoxManager.isSelected())); - - itemExit.addActionListener( - e -> dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING))); - - itemCluster.addActionListener( - arg0 -> { - if (currentResult.canCluster()) { - final DistanceMatrix distanceMatrix = currentResult.distanceMatrix(); - final double[][] array = distanceMatrix.matrix(); - - if (array.length <= 1) { - final String message = - "Cannot cluster this distance matrix, because" - + " it contains zero valid comparisons"; - JOptionPane.showMessageDialog(null, message, "Warning", JOptionPane.WARNING_MESSAGE); - return; - } - - final DialogCluster dialogClustering = new DialogCluster(distanceMatrix); - dialogClustering.setVisible(true); - } - }); - - itemGuide.addActionListener( - e -> { - final DialogGuide dialog = new DialogGuide(this); - dialog.setVisible(true); - }); - - itemAbout.addActionListener( - e -> { - final DialogAbout dialog = new DialogAbout(this); - dialog.setVisible(true); - }); + if (currentResult.canExport()) { + itemSave.setText("Save results"); } + } - private void saveResults() { - if (currentResult.canExport()) { - final File suggestedName = currentResult.suggestName(); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setSelectedFile(suggestedName); - - if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { - try (final OutputStream stream = new FileOutputStream(fileChooser.getSelectedFile())) { - currentResult.export(stream); - JOptionPane.showMessageDialog( - this, - "Successfully exported the " + "results!", - "Information", - JOptionPane.INFORMATION_MESSAGE); - } catch (final IOException e) { - JOptionPane.showMessageDialog( - this, - "Failed to export the " + "results, reason: " + e.getMessage(), - "Error", - JOptionPane.ERROR_MESSAGE); - } - } - } + private void selectStructures() { + if (dialogStructures.showDialog() != OkCancelOption.OK) { + return; } - private void selectSingleStructure() { - itemSave.setEnabled(false); - - final List names = StructureManager.getAllNames(); - final String[] selectionValues = names.toArray(new String[0]); - final String name = - (String) - JOptionPane.showInputDialog( - this, - "Select structure", - "Represent structure in torsion angle space", - JOptionPane.QUESTION_MESSAGE, - null, - selectionValues, - null); - - if (name != null) { - final PdbModel structure = StructureManager.getStructure(name); - currentResult = panelTorsionAngles.calculateTorsionAngles(structure); - layoutCards.show(panelCards, MainWindow.CARD_TORSION); - updateMenuEnabledStates(); - } + final List structures = dialogStructures.getStructures(); + if (structures.size() < 2) { + JOptionPane.showMessageDialog( + this, + "At least two structures must be selected to compute global distance", + "Information", + JOptionPane.INFORMATION_MESSAGE); + return; } - private void updateMenuEnabledStates() { - itemSave.setEnabled(currentResult.canExport()); - itemCluster.setEnabled(currentResult.canCluster()); - - if (currentResult.canExport()) { - itemSave.setText("Save results"); - } + itemSave.setEnabled(false); + itemCluster.setEnabled(false); + + panelResultsGlobalMatrix.setStructures(structures); + layoutCards.show(panelCards, MainWindow.CARD_GLOBAL_MATRIX); + compareGlobal(); + } + + private void compareGlobal() { + final GlobalComparator comparator; + if (radioGlobalLcs.isSelected()) { + final Angle threshold = + ImmutableAngle.of( + FastMath.toRadians( + Double.parseDouble(JOptionPane.showInputDialog("MCQ threshold:")))); + comparator = new LCS(MoleculeType.RNA, threshold); + } else if (radioGlobalMcq.isSelected()) { + comparator = ImmutableMCQ.of(MoleculeType.RNA); + } else { + comparator = new RMSD(MoleculeType.RNA); } - private void selectStructures() { - if (dialogStructures.showDialog() != OkCancelOption.OK) { - return; - } - - final List structures = dialogStructures.getStructures(); - if (structures.size() < 2) { - JOptionPane.showMessageDialog( - this, - "At least two structures must be selected to compute global distance", - "Information", - JOptionPane.INFORMATION_MESSAGE); - return; - } - - itemSave.setEnabled(false); - itemCluster.setEnabled(false); - - panelResultsGlobalMatrix.setStructures(structures); - layoutCards.show(panelCards, MainWindow.CARD_GLOBAL_MATRIX); - compareGlobal(); + panelResultsGlobalMatrix.compareAndDisplayMatrix( + comparator, + processingResult -> { + currentResult = processingResult; + layoutCards.show(panelCards, MainWindow.CARD_GLOBAL_MATRIX); + updateMenuEnabledStates(); + }); + } + + private void selectChains(final JMenuItem source) { + if (dialogChains.showDialog() != OkCancelOption.OK) { + return; } - private void compareGlobal() { - final GlobalComparator comparator; - if (radioGlobalLcs.isSelected()) { - final Angle threshold = - ImmutableAngle.of( - FastMath.toRadians( - Double.parseDouble(JOptionPane.showInputDialog("MCQ threshold:")))); - comparator = new LCS(MoleculeType.RNA, threshold); - } else if (radioGlobalMcq.isSelected()) { - comparator = ImmutableMCQ.of(MoleculeType.RNA); - } else { - comparator = new RMSD(MoleculeType.RNA); - } - - panelResultsGlobalMatrix.compareAndDisplayMatrix( - comparator, - processingResult -> { - currentResult = processingResult; - layoutCards.show(panelCards, MainWindow.CARD_GLOBAL_MATRIX); - updateMenuEnabledStates(); - }); + final Pair structures = dialogChains.getStructures(); + final Pair, List> chains = dialogChains.getChains(); + + if (chains.getLeft().isEmpty() || chains.getRight().isEmpty()) { + final String message = + "No chains specified for structure: " + + StructureManager.getName(structures.getLeft()) + + " or " + + StructureManager.getName(structures.getRight()); + JOptionPane.showMessageDialog(this, message, "Information", JOptionPane.INFORMATION_MESSAGE); + return; } - private void selectChains(final JMenuItem source) { - if (dialogChains.showDialog() != OkCancelOption.OK) { - return; - } - - final Pair structures = dialogChains.getStructures(); - final Pair, List> chains = dialogChains.getChains(); - - if (chains.getLeft().isEmpty() || chains.getRight().isEmpty()) { - final String message = - "No chains specified for structure: " - + StructureManager.getName(structures.getLeft()) - + " or " - + StructureManager.getName(structures.getRight()); - JOptionPane.showMessageDialog(this, message, "Information", JOptionPane.INFORMATION_MESSAGE); - return; - } - - if (source.equals(itemSelectStructuresCompare)) { - itemSave.setEnabled(false); - itemCluster.setEnabled(false); + if (source.equals(itemSelectStructuresCompare)) { + itemSave.setEnabled(false); + itemCluster.setEnabled(false); - panelResultsLocalMatrix.setStructuresAndChains(structures, chains); - layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MATRIX); - compareLocalPair(); - } + panelResultsLocalMatrix.setStructuresAndChains(structures, chains); + layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MATRIX); + compareLocalPair(); } + } - private void compareLocalPair() { - if (dialogAngles.showDialog() == OkCancelOption.OK) { - currentResult = panelResultsLocalMatrix.compareAndDisplayTable(dialogAngles.getAngles()); - layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MATRIX); - updateMenuEnabledStates(); - } + private void compareLocalPair() { + if (dialogAngles.showDialog() == OkCancelOption.OK) { + currentResult = panelResultsLocalMatrix.compareAndDisplayTable(dialogAngles.getAngles()); + layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MATRIX); + updateMenuEnabledStates(); } + } - private void selectChainsMultiple(final JMenuItem source) { - if (dialogChainsMultiple.showDialog(source.equals(itemSelectStructuresCompare)) - != OkCancelOption.OK) { - return; - } + private void selectChainsMultiple(final JMenuItem source) { + if (dialogChainsMultiple.showDialog(source.equals(itemSelectStructuresCompare)) + != OkCancelOption.OK) { + return; + } - if (dialogChainsMultiple.getChains().size() < 2) { - JOptionPane.showMessageDialog( - this, - "You have to select at least two " + "chains", - "Warning", - JOptionPane.WARNING_MESSAGE); - return; - } + if (dialogChainsMultiple.getChains().size() < 2) { + JOptionPane.showMessageDialog( + this, + "You have to select at least two " + "chains", + "Warning", + JOptionPane.WARNING_MESSAGE); + return; + } - final List fragments = dialogChainsMultiple.getChains(); - final MoleculeType type = fragments.get(0).moleculeType(); - - for (final PdbCompactFragment c : fragments) { - if (type != c.moleculeType()) { - JOptionPane.showMessageDialog( - this, - "Cannot align/compare " + "structures: different " + "types", - "Error", - JOptionPane.ERROR_MESSAGE); - return; - } - } + final List fragments = dialogChainsMultiple.getChains(); + final MoleculeType type = fragments.get(0).moleculeType(); + + for (final PdbCompactFragment c : fragments) { + if (type != c.moleculeType()) { + JOptionPane.showMessageDialog( + this, + "Cannot align/compare " + "structures: different " + "types", + "Error", + JOptionPane.ERROR_MESSAGE); + return; + } + } - if (source.equals(itemSelectStructuresCompare)) { - itemSave.setEnabled(false); - itemCluster.setEnabled(false); + if (source.equals(itemSelectStructuresCompare)) { + itemSave.setEnabled(false); + itemCluster.setEnabled(false); - panelResultsLocalMultiMatrix.setFragments(fragments); - layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MULTI_MATRIX); - compareLocalMulti(); - } + panelResultsLocalMultiMatrix.setFragments(fragments); + layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MULTI_MATRIX); + compareLocalMulti(); } + } - private void compareLocalMulti() { - currentResult = panelResultsLocalMultiMatrix.compareAndDisplayTable(); - layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MULTI_MATRIX); - updateMenuEnabledStates(); - } + private void compareLocalMulti() { + currentResult = panelResultsLocalMultiMatrix.compareAndDisplayTable(); + layoutCards.show(panelCards, MainWindow.CARD_LOCAL_MULTI_MATRIX); + updateMenuEnabledStates(); + } } diff --git a/mcq-gui/src/main/java/pl/poznan/put/gui/window/SVGDialog.java b/mcq-gui/src/main/java/pl/poznan/put/gui/window/SVGDialog.java index 86af9df9..ffd087f3 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/gui/window/SVGDialog.java +++ b/mcq-gui/src/main/java/pl/poznan/put/gui/window/SVGDialog.java @@ -1,12 +1,11 @@ package pl.poznan.put.gui.window; +import java.awt.*; +import javax.swing.*; import org.w3c.dom.svg.SVGDocument; import pl.poznan.put.gui.component.SVGComponent; import pl.poznan.put.utility.svg.Format; -import javax.swing.*; -import java.awt.*; - class SVGDialog extends JDialog { private final SVGComponent svgComponent; diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/AbstractDrawable.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/AbstractDrawable.java index 5f4d9979..8f5c25a5 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/AbstractDrawable.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/AbstractDrawable.java @@ -1,14 +1,13 @@ package pl.poznan.put.visualisation; +import java.awt.geom.Rectangle2D; +import java.util.Locale; import org.apache.batik.svggen.SVGGraphics2D; import org.apache.batik.util.SVGConstants; import org.w3c.dom.svg.SVGDocument; import org.w3c.dom.svg.SVGSVGElement; import pl.poznan.put.utility.svg.SVGHelper; -import java.awt.geom.Rectangle2D; -import java.util.Locale; - public abstract class AbstractDrawable implements Drawable { protected SVGDocument svgDocument = SVGHelper.emptyDocument(); protected SVGGraphics2D svgGraphics = new SVGGraphics2D(svgDocument); diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/AngularHistogram.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/AngularHistogram.java index 084b500c..5eccfafa 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/AngularHistogram.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/AngularHistogram.java @@ -1,5 +1,6 @@ package pl.poznan.put.visualisation; +import java.util.Collection; import org.apache.batik.ext.awt.geom.Polygon2D; import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.MathUtils; @@ -8,8 +9,6 @@ import pl.poznan.put.circular.ImmutableHistogram; import pl.poznan.put.circular.enums.AngleTransformation; -import java.util.Collection; - public class AngularHistogram extends RawDataPlot { private final double binRadians; private double scalingFactor; diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/RawDataPlot.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/RawDataPlot.java index 0ac70176..8d4b428f 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/RawDataPlot.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/RawDataPlot.java @@ -1,14 +1,5 @@ package pl.poznan.put.visualisation; -import org.apache.batik.ext.awt.geom.Polygon2D; -import org.apache.commons.math3.util.FastMath; -import org.apache.commons.math3.util.MathUtils; -import pl.poznan.put.circular.Angle; -import pl.poznan.put.circular.enums.AngleTransformation; -import pl.poznan.put.circular.exception.InvalidCircularOperationException; -import pl.poznan.put.constant.Unicode; -import pl.poznan.put.utility.svg.SVGHelper; - import java.awt.FontMetrics; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; @@ -19,6 +10,13 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.apache.batik.ext.awt.geom.Polygon2D; +import org.apache.commons.math3.util.FastMath; +import org.apache.commons.math3.util.MathUtils; +import pl.poznan.put.circular.Angle; +import pl.poznan.put.circular.enums.AngleTransformation; +import pl.poznan.put.circular.exception.InvalidCircularOperationException; +import pl.poznan.put.constant.Unicode; public class RawDataPlot extends AbstractDrawable { private final Collection data; diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/TorsionAxis.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/TorsionAxis.java index 1674bed3..a9d0b12b 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/TorsionAxis.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/TorsionAxis.java @@ -1,16 +1,15 @@ package pl.poznan.put.visualisation; -import org.apache.commons.math3.util.Precision; -import org.jfree.chart.axis.AxisState; -import org.jfree.chart.axis.NumberAxis; -import org.jfree.chart.axis.NumberTick; -import org.jfree.chart.ui.RectangleEdge; - import java.awt.*; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.commons.math3.util.Precision; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.NumberTick; +import org.jfree.chart.ui.RectangleEdge; public final class TorsionAxis extends NumberAxis { private static final long serialVersionUID = 688243119045973269L; diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableFragmentMatch.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableFragmentMatch.java index 23665d30..9fad8a20 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableFragmentMatch.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableFragmentMatch.java @@ -1,5 +1,14 @@ package pl.poznan.put.visualisation; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import lombok.extern.slf4j.Slf4j; import org.apache.batik.svggen.SVGGraphics2D; import org.apache.batik.util.SVGConstants; @@ -31,16 +40,6 @@ import pl.poznan.put.utility.AngleFormat; import pl.poznan.put.utility.svg.SVGHelper; -import java.awt.Dimension; -import java.awt.Rectangle; -import java.awt.geom.Rectangle2D; -import java.text.FieldPosition; -import java.text.NumberFormat; -import java.text.ParsePosition; -import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - @Slf4j public class VisualizableFragmentMatch extends FragmentMatch implements Visualizable { private static final double[] PERCENTS_FROM_1_TO_100 = diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableGlobalMatrix.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableGlobalMatrix.java index 2b1f9dc2..27594706 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableGlobalMatrix.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableGlobalMatrix.java @@ -1,5 +1,7 @@ package pl.poznan.put.visualisation; +import java.util.NavigableMap; +import java.util.TreeMap; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; @@ -12,11 +14,6 @@ import pl.poznan.put.types.DistanceMatrix; import pl.poznan.put.utility.svg.SVGHelper; -import javax.swing.JOptionPane; -import java.util.List; -import java.util.NavigableMap; -import java.util.TreeMap; - @Data @EqualsAndHashCode(callSuper = true) @Slf4j @@ -40,9 +37,7 @@ public final SVGDocument visualize() { } @Override - public void visualize3D() { - - } + public void visualize3D() {} private NavigableMap prepareTicksZ() { final NavigableMap valueTickZ = new TreeMap<>(); diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableMCQLocalResult.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableMCQLocalResult.java index 229fb0af..e9248264 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableMCQLocalResult.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableMCQLocalResult.java @@ -1,5 +1,9 @@ package pl.poznan.put.visualisation; +import java.util.List; +import java.util.NavigableMap; +import java.util.TreeMap; +import java.util.stream.Collectors; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.w3c.dom.svg.SVGDocument; @@ -9,16 +13,8 @@ import pl.poznan.put.interfaces.Visualizable; import pl.poznan.put.matching.FragmentMatch; import pl.poznan.put.matching.ResidueComparison; -import pl.poznan.put.pdb.analysis.MoleculeType; -import pl.poznan.put.pdb.analysis.PdbCompactFragment; import pl.poznan.put.torsion.MasterTorsionAngleType; -import javax.swing.JOptionPane; -import java.util.List; -import java.util.NavigableMap; -import java.util.TreeMap; -import java.util.stream.Collectors; - @Data @Slf4j public abstract class VisualizableMCQLocalResult implements LocalResult, Visualizable { diff --git a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableSelectedAngle.java b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableSelectedAngle.java index a370a810..067800d7 100644 --- a/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableSelectedAngle.java +++ b/mcq-gui/src/main/java/pl/poznan/put/visualisation/VisualizableSelectedAngle.java @@ -1,5 +1,13 @@ package pl.poznan.put.visualisation; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Shape; +import java.awt.font.LineMetrics; +import java.awt.geom.Rectangle2D; +import java.util.List; +import java.util.stream.Collectors; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; @@ -28,17 +36,6 @@ import pl.poznan.put.torsion.TorsionAngleDelta; import pl.poznan.put.utility.svg.SVGHelper; -import javax.swing.JOptionPane; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.Shape; -import java.awt.font.LineMetrics; -import java.awt.geom.Rectangle2D; -import java.util.List; -import java.util.NavigableMap; -import java.util.stream.Collectors; - @Data @EqualsAndHashCode(callSuper = true) @Slf4j @@ -95,9 +92,7 @@ public final SVGDocument visualize() { } @Override - public void visualize3D() { - - } + public void visualize3D() {} private float drawModelsNames( final SVGGraphics2D svg, final float unitHeight, final float descent) { diff --git a/mcq-ws/pom.xml b/mcq-ws/pom.xml index fd08c4a6..062bfbf7 100644 --- a/mcq-ws/pom.xml +++ b/mcq-ws/pom.xml @@ -4,7 +4,7 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 mcq-ws @@ -61,6 +61,11 @@ + + com.diffplug.spotless + spotless-maven-plugin + + org.jsonschema2pojo jsonschema2pojo-maven-plugin diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/Controller.java b/mcq-ws/src/main/java/pl/poznan/put/ws/Controller.java index 2c025e47..47ba8bc8 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/Controller.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/Controller.java @@ -1,12 +1,11 @@ package pl.poznan.put.ws; +import java.util.List; +import javax.validation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import pl.poznan.put.schema.*; import pl.poznan.put.ws.components.Version; -import java.util.List; - -import javax.validation.Valid; @RestController @RequestMapping("/api") diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/ControllerAdvice.java b/mcq-ws/src/main/java/pl/poznan/put/ws/ControllerAdvice.java index 37f6361e..32167ea3 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/ControllerAdvice.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/ControllerAdvice.java @@ -20,7 +20,6 @@ private String illegalArgumentExceptionHandler( return illegalArgumentException.getMessage(); } - @ResponseBody @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) @ExceptionHandler(NoGitPropertiesException.class) diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/ServicesSupervisor.java b/mcq-ws/src/main/java/pl/poznan/put/ws/ServicesSupervisor.java index e9346cf7..62183008 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/ServicesSupervisor.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/ServicesSupervisor.java @@ -19,7 +19,10 @@ public class ServicesSupervisor { @Autowired public ServicesSupervisor( - VersionService versionService, UploadService uploadService, AnalyzeService analyzeService, CompareService compareService) { + VersionService versionService, + UploadService uploadService, + AnalyzeService analyzeService, + CompareService compareService) { this.versionService = versionService; this.uploadService = uploadService; this.analyzeService = analyzeService; diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/WebConfig.java b/mcq-ws/src/main/java/pl/poznan/put/ws/WebConfig.java index 78e2239a..54c3585b 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/WebConfig.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/WebConfig.java @@ -1,5 +1,7 @@ package pl.poznan.put.ws; +import java.time.Instant; +import java.util.UUID; import org.modelmapper.Converter; import org.modelmapper.ModelMapper; import org.springframework.context.annotation.Bean; @@ -10,9 +12,6 @@ import pl.poznan.put.schema.UploadDTO; import pl.poznan.put.ws.entities.StructureContent; -import java.time.Instant; -import java.util.UUID; - @Configuration public class WebConfig { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Chain.java b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Chain.java index 74ab214c..a759b974 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Chain.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Chain.java @@ -1,25 +1,17 @@ package pl.poznan.put.ws.entities; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -import javax.annotation.Generated; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; import javax.persistence.Entity; -import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.OneToMany; import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - @Entity public class Chain { - @Id - private String name; + @Id private String name; @Valid @OneToMany(targetEntity = Residue.class, mappedBy = "residueNumber") @@ -51,10 +43,7 @@ public void setResidues(List residues) { @Override public String toString() { - return "Chain{" + - "name='" + name + '\'' + - ", residues=" + residues + - '}'; + return "Chain{" + "name='" + name + '\'' + ", residues=" + residues + '}'; } @Override diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Residue.java b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Residue.java index d6ee5caf..7b87ef08 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Residue.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/Residue.java @@ -1,13 +1,8 @@ package pl.poznan.put.ws.entities; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -import javax.annotation.Generated; +import java.util.Objects; import javax.persistence.Entity; import javax.persistence.Id; -import java.util.Objects; @Entity public class Residue { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/StructureContent.java b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/StructureContent.java index d715789a..b61c5938 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/StructureContent.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/StructureContent.java @@ -1,17 +1,11 @@ package pl.poznan.put.ws.entities; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import org.springframework.data.annotation.CreatedDate; - -import javax.annotation.Generated; -import javax.persistence.*; -import javax.validation.constraints.Pattern; import java.time.Instant; +import java.util.List; import java.util.Objects; import java.util.UUID; -import java.util.List; +import javax.persistence.*; +import org.springframework.data.annotation.CreatedDate; @Entity public class StructureContent { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/TrigonometricRepresentation.java b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/TrigonometricRepresentation.java index bd2b29cc..cf123d38 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/entities/TrigonometricRepresentation.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/entities/TrigonometricRepresentation.java @@ -1,18 +1,12 @@ package pl.poznan.put.ws.entities; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import pl.poznan.put.schema.ChainDTO; - -import javax.annotation.Generated; -import javax.persistence.*; -import javax.validation.Valid; import java.time.Instant; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.UUID; +import javax.persistence.*; +import javax.validation.Valid; @Entity public class TrigonometricRepresentation { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/exceptions/NoGitPropertiesException.java b/mcq-ws/src/main/java/pl/poznan/put/ws/exceptions/NoGitPropertiesException.java index 899a6694..3649b852 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/exceptions/NoGitPropertiesException.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/exceptions/NoGitPropertiesException.java @@ -1,7 +1,7 @@ package pl.poznan.put.ws.exceptions; -public class NoGitPropertiesException extends RuntimeException{ - public NoGitPropertiesException() { - super("File git.properties has not been found!"); - } +public class NoGitPropertiesException extends RuntimeException { + public NoGitPropertiesException() { + super("File git.properties has not been found!"); + } } diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/StructureContentCrudRepo.java b/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/StructureContentCrudRepo.java index 29866f13..d604e14c 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/StructureContentCrudRepo.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/StructureContentCrudRepo.java @@ -1,12 +1,11 @@ package pl.poznan.put.ws.jpa; +import java.util.Optional; +import java.util.UUID; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import pl.poznan.put.ws.entities.StructureContent; -import java.util.Optional; -import java.util.UUID; - @Repository public interface StructureContentCrudRepo extends CrudRepository { Optional findByData(String data); diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/TrigonometricRepresentationCrudRepo.java b/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/TrigonometricRepresentationCrudRepo.java index 241b583d..546a9834 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/TrigonometricRepresentationCrudRepo.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/jpa/TrigonometricRepresentationCrudRepo.java @@ -1,13 +1,11 @@ package pl.poznan.put.ws.jpa; +import java.util.List; +import java.util.UUID; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; import pl.poznan.put.ws.entities.TrigonometricRepresentation; -import java.util.List; - -import java.util.Optional; -import java.util.UUID; public interface TrigonometricRepresentationCrudRepo extends CrudRepository { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/services/AnalyzeService.java b/mcq-ws/src/main/java/pl/poznan/put/ws/services/AnalyzeService.java index 0ad2bbf5..4a33f8e6 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/services/AnalyzeService.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/services/AnalyzeService.java @@ -1,5 +1,9 @@ package pl.poznan.put.ws.services; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.Collectors; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -9,16 +13,9 @@ import pl.poznan.put.ws.entities.TrigonometricRepresentation; import pl.poznan.put.ws.exceptions.ObjectNotFoundException; import pl.poznan.put.ws.jpa.StructureContentCrudRepo; - import pl.poznan.put.ws.jpa.TrigonometricRepresentationCrudRepo; import pl.poznan.put.ws.services.subservices.ComputationService; -import java.util.ArrayList; -import java.util.Optional; -import java.util.UUID; -import java.util.List; -import java.util.stream.Collectors; - @Service public class AnalyzeService { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/services/CompareService.java b/mcq-ws/src/main/java/pl/poznan/put/ws/services/CompareService.java index f6845c6e..45719c41 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/services/CompareService.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/services/CompareService.java @@ -1,12 +1,10 @@ package pl.poznan.put.ws.services; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; import java.util.stream.StreamSupport; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import pl.poznan.put.schema.ModelComparisonDTO; @@ -55,10 +53,10 @@ public List handleCompare(List chains, String modelT false) .collect(Collectors.toList()); - if (modelTarget != null) { - List targets = trigonometricRepresentationCrudRepo.findAllByInputId(UUID.fromString(modelTarget)); - if (targets.size() == 1){ + List targets = + trigonometricRepresentationCrudRepo.findAllByInputId(UUID.fromString(modelTarget)); + if (targets.size() == 1) { return computationService.compare(trigonometricRepresentations, targets.get(0)); } else { throw new ObjectNotFoundException(modelTarget, TrigonometricRepresentation.class); diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/services/UploadService.java b/mcq-ws/src/main/java/pl/poznan/put/ws/services/UploadService.java index 5d0bca92..cd4f6c97 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/services/UploadService.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/services/UploadService.java @@ -1,5 +1,6 @@ package pl.poznan.put.ws.services; +import java.util.Optional; import org.modelmapper.ModelMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -10,8 +11,6 @@ import pl.poznan.put.ws.jpa.StructureContentCrudRepo; import pl.poznan.put.ws.services.subservices.ComputationService; -import java.util.Optional; - @Service public class UploadService { @@ -52,11 +51,13 @@ public UploadDTO handlePostUpload(String pdbId, int assemblyId) { private void validateParameters(String pdbId, int assemblyId) { if (pdbId.length() != 4) { - throw new PathVariableException("pdbId", pdbId, "This parameter has to contain 4 characters!"); + throw new PathVariableException( + "pdbId", pdbId, "This parameter has to contain 4 characters!"); } if (assemblyId < 1) { - throw new PathVariableException("assemblyId", String.valueOf(assemblyId), "This number has to be positive!"); + throw new PathVariableException( + "assemblyId", String.valueOf(assemblyId), "This number has to be positive!"); } } } diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/services/VersionService.java b/mcq-ws/src/main/java/pl/poznan/put/ws/services/VersionService.java index abc8d16e..b3fa456f 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/services/VersionService.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/services/VersionService.java @@ -2,8 +2,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import pl.poznan.put.ws.exceptions.NoGitPropertiesException; import pl.poznan.put.ws.components.Version; +import pl.poznan.put.ws.exceptions.NoGitPropertiesException; @Service public class VersionService { diff --git a/mcq-ws/src/main/java/pl/poznan/put/ws/services/subservices/ComputationService.java b/mcq-ws/src/main/java/pl/poznan/put/ws/services/subservices/ComputationService.java index c4908478..3c362baa 100644 --- a/mcq-ws/src/main/java/pl/poznan/put/ws/services/subservices/ComputationService.java +++ b/mcq-ws/src/main/java/pl/poznan/put/ws/services/subservices/ComputationService.java @@ -1,12 +1,11 @@ package pl.poznan.put.ws.services.subservices; +import java.util.List; import org.springframework.stereotype.Service; import pl.poznan.put.schema.ModelComparisonDTO; import pl.poznan.put.schema.StructureContentDTO; import pl.poznan.put.ws.entities.TrigonometricRepresentation; -import java.util.List; - @Service public class ComputationService { public StructureContentDTO loadStructure(String pdbId, int assemblyId) { @@ -21,7 +20,8 @@ public List compare(List target return null; } - public List compare(List model, TrigonometricRepresentation target) { + public List compare( + List model, TrigonometricRepresentation target) { return null; } } diff --git a/pom.xml b/pom.xml index 01e84770..1f18d117 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ pl.poznan.put mcq-parent - 1.7.0 + 1.8.0 pom @@ -66,7 +66,7 @@ me.tongfei progressbar - 0.9.3 + 0.9.4 @@ -126,7 +126,7 @@ org.immutables value - 2.9.1 + 2.9.2 @@ -156,37 +156,37 @@ org.springframework spring-core - 5.3.20 + 5.3.22 org.springframework.boot spring-boot-maven-plugin - 2.4.5 + 2.7.3 org.springframework.boot spring-boot-starter-data-jpa - 2.4.5 + 2.7.3 org.springframework.boot spring-boot-starter-test - 2.3.10.RELEASE + 2.7.3 org.springframework.boot spring-boot-starter-validation - 2.4.5 + 2.7.3 org.springframework.boot spring-boot-starter-web - 2.5.12 + 2.7.3 @@ -198,7 +198,7 @@ org.mockito mockito-core - 4.7.0 + 4.8.0 test @@ -215,17 +215,32 @@ - com.github.ekryd.sortpom - sortpom-maven-plugin - 2.11.0 + com.diffplug.spotless + spotless-maven-plugin + 2.25.0 + + + + + + true + + + - verify - sort + apply + compile + + + + com.github.ekryd.sortpom + sortpom-maven-plugin + 3.2.0 \n UTF-8 @@ -234,32 +249,40 @@ scope,groupId,artifactId groupId,artifactId + + + + sort + + verify + + org.apache.maven.plugins maven-assembly-plugin - 3.2.0 + 3.4.2 + + + jar-with-dependencies + + make-assembly - package single + package - - - jar-with-dependencies - - org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.10.1 11 11 @@ -269,12 +292,17 @@ org.codehaus.mojo versions-maven-plugin - 2.7 + 2.12.0 + + com.diffplug.spotless + spotless-maven-plugin + + com.github.ekryd.sortpom sortpom-maven-plugin @@ -302,13 +330,17 @@ org.springframework.boot spring-boot-maven-plugin - 2.3.10.RELEASE + 2.7.3 pl.project13.maven git-commit-id-plugin 4.9.10 + + true + false + get-the-git-infos @@ -317,10 +349,6 @@ - - true - false -