From a059dd46fe149a476bd274562cd27b2dc7d390dd Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 24 Jun 2022 17:24:51 +0100 Subject: [PATCH] JAL-2349 JAL-3855 formatting --- src/jalview/renderer/ContactMapRenderer.java | 14 +++--- src/jalview/ws/dbsources/EBIAlfaFold.java | 65 ++++++++++++-------------- test/jalview/datamodel/AlignmentTest.java | 20 ++++---- 3 files changed, 46 insertions(+), 53 deletions(-) diff --git a/src/jalview/renderer/ContactMapRenderer.java b/src/jalview/renderer/ContactMapRenderer.java index 7a052da..10f87b1 100644 --- a/src/jalview/renderer/ContactMapRenderer.java +++ b/src/jalview/renderer/ContactMapRenderer.java @@ -3,6 +3,9 @@ */ package jalview.renderer; +import java.awt.Color; +import java.awt.Graphics; + import jalview.api.AlignViewportI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.Annotation; @@ -12,9 +15,6 @@ import jalview.datamodel.ContactRange; import jalview.datamodel.HiddenColumns; import jalview.renderer.api.AnnotationRowRendererI; -import java.awt.Color; -import java.awt.Graphics; - /** * @author jprocter * @@ -24,10 +24,10 @@ public class ContactMapRenderer implements AnnotationRowRendererI @Override public void renderRow(Graphics g, int charWidth, int charHeight, - boolean hasHiddenColumns, AlignViewportI viewport, HiddenColumns hiddenColumns, - ColumnSelection columnSelection, AlignmentAnnotation _aa, - Annotation[] aa_annotations, int sRes, int eRes, float min, - float max, int y) + boolean hasHiddenColumns, AlignViewportI viewport, + HiddenColumns hiddenColumns, ColumnSelection columnSelection, + AlignmentAnnotation _aa, Annotation[] aa_annotations, int sRes, + int eRes, float min, float max, int y) { if (sRes > aa_annotations.length) { diff --git a/src/jalview/ws/dbsources/EBIAlfaFold.java b/src/jalview/ws/dbsources/EBIAlfaFold.java index 97eacab..e0ab54d 100644 --- a/src/jalview/ws/dbsources/EBIAlfaFold.java +++ b/src/jalview/ws/dbsources/EBIAlfaFold.java @@ -21,45 +21,33 @@ */ package jalview.ws.dbsources; +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.stevesoft.pat.Regex; + import jalview.api.FeatureSettingsModelI; -import jalview.bin.Cache; import jalview.bin.Console; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; -import jalview.datamodel.ContactMatrix; import jalview.datamodel.ContactMatrixI; import jalview.datamodel.DBRefEntry; -import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; -import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.datamodel.features.SequenceFeaturesI; import jalview.io.DataSourceType; import jalview.io.FileFormat; import jalview.io.FileFormatI; import jalview.io.FormatAdapter; import jalview.io.PDBFeatureSettings; -import jalview.javascript.json.JSON; -import jalview.structure.StructureImportSettings; -import jalview.util.HttpUtils; import jalview.util.MessageManager; import jalview.util.Platform; import jalview.ws.datamodel.alphafold.PAEContactMatrix; -import jalview.ws.ebi.EBIFetchClient; import jalview.ws.utils.UrlDownloadClient; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.jmol.adapter.readers.simple.JSONReader; - -import com.stevesoft.pat.Regex; - /** * @author JimP * @@ -188,7 +176,8 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy try { File tmpFile = File.createTempFile(id, ".cif"); - Console.debug("Retrieving structure file for "+id+" from "+alphaFoldCif); + Console.debug("Retrieving structure file for " + id + " from " + + alphaFoldCif); UrlDownloadClient.download(alphaFoldCif, tmpFile); // may not need this check ? @@ -216,20 +205,23 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy if (retrievalUrl != null) { // manufacture the PAE url from a url like ...-model-vN.cif - paeURL = retrievalUrl.replace("model","predicted_aligned_error").replace(".cif",".json"); + paeURL = retrievalUrl.replace("model", "predicted_aligned_error") + .replace(".cif", ".json"); } - Console.debug("Downloading pae from " + paeURL - + " to " + pae.toString() + ""); + Console.debug("Downloading pae from " + paeURL + " to " + + pae.toString() + ""); - try { - UrlDownloadClient.download(paeURL, pae); - if (!importPaeJSONAsContactMatrix(pdbAlignment, pae)) + try { - Console.warn("Couln't import contact matrix from " + paeURL - + " (stored in " + pae.toString() + ")"); - } - } catch (Exception pae_ex) { - Console.debug("Couldn't download PAE",pae_ex); + UrlDownloadClient.download(paeURL, pae); + if (!importPaeJSONAsContactMatrix(pdbAlignment, pae)) + { + Console.warn("Couln't import contact matrix from " + paeURL + + " (stored in " + pae.toString() + ")"); + } + } catch (Exception pae_ex) + { + Console.debug("Couldn't download PAE", pae_ex); } } catch (Exception ex) // Problem parsing PDB file @@ -245,16 +237,17 @@ public class EBIAlfaFold extends EbiFileRetrievedProxy { FileInputStream pae_input = new FileInputStream(pae); - List pae_obj = (List) Platform - .parseJSON(pae_input); + List pae_obj = (List) Platform.parseJSON(pae_input); if (pae_obj == null) { return false; } ContactMatrixI matrix = new PAEContactMatrix( - pdbAlignment.getSequenceAt(0), (Map)pae_obj.get(0)); + pdbAlignment.getSequenceAt(0), + (Map) pae_obj.get(0)); - pdbAlignment.getSequenceAt(0).addAlignmentAnnotation(pdbAlignment.addContactList(matrix)); + pdbAlignment.getSequenceAt(0) + .addAlignmentAnnotation(pdbAlignment.addContactList(matrix)); return true; } diff --git a/test/jalview/datamodel/AlignmentTest.java b/test/jalview/datamodel/AlignmentTest.java index d00abb1..4b1f7e9 100644 --- a/test/jalview/datamodel/AlignmentTest.java +++ b/test/jalview/datamodel/AlignmentTest.java @@ -27,16 +27,6 @@ import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; -import jalview.analysis.AlignmentGenerator; -import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; -import jalview.gui.JvOptionPane; -import jalview.io.DataSourceType; -import jalview.io.FileFormat; -import jalview.io.FileFormatI; -import jalview.io.FormatAdapter; -import jalview.util.Comparison; -import jalview.util.MapList; - import java.io.IOException; import java.util.Arrays; import java.util.Iterator; @@ -47,6 +37,16 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; +import jalview.analysis.AlignmentGenerator; +import jalview.datamodel.AlignedCodonFrame.SequenceToSequenceMapping; +import jalview.gui.JvOptionPane; +import jalview.io.DataSourceType; +import jalview.io.FileFormat; +import jalview.io.FileFormatI; +import jalview.io.FormatAdapter; +import jalview.util.Comparison; +import jalview.util.MapList; + /** * Unit tests for Alignment datamodel. * -- 1.7.10.2