From df3da405342b96c6630e280a2ac407864ac3a62f Mon Sep 17 00:00:00 2001 From: James Procter Date: Wed, 22 Feb 2023 14:23:15 +0000 Subject: [PATCH] JAL-3858 construct a PAE direct from float array --- .../ws/datamodel/alphafold/PAEContactMatrix.java | 41 +++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java index 79ad458..58a4a83 100644 --- a/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java +++ b/src/jalview/ws/datamodel/alphafold/PAEContactMatrix.java @@ -29,17 +29,21 @@ public class PAEContactMatrix implements ContactMatrixI float maxscore; - @SuppressWarnings("unchecked") - public PAEContactMatrix(SequenceI _refSeq, Map pae_obj) + private void setRefSeq(SequenceI _refSeq) { refSeq = _refSeq; while (refSeq.getDatasetSequence() != null) { refSeq = refSeq.getDatasetSequence(); } - // convert the lists to primitive arrays and store length = _refSeq.getEnd() - _refSeq.getStart() + 1; - + } + @SuppressWarnings("unchecked") + public PAEContactMatrix(SequenceI _refSeq, Map pae_obj) + { + setRefSeq(_refSeq); + // convert the lists to primitive arrays and store + if (!MapUtils.containsAKey(pae_obj, "predicted_aligned_error", "pae")) { parse_version_1_pAE(pae_obj); @@ -50,12 +54,39 @@ public class PAEContactMatrix implements ContactMatrixI parse_version_2_pAE(pae_obj); } } + /** + * construct a sequence associated PAE matrix directly from a float array + * @param _refSeq + * @param matrix + */ + public PAEContactMatrix(SequenceI _refSeq, float[][] matrix) + { + setRefSeq(_refSeq); + maxcol=0; + for (float[] row:matrix) + { + if (row.length>maxcol) + { + maxcol=row.length; + } + maxscore=row[0]; + for (float f:row) + { + if (maxscore pae_obj) { elements = new float[length][length]; @@ -86,6 +117,7 @@ public class PAEContactMatrix implements ContactMatrixI * * @param pae_obj */ + @SuppressWarnings("unchecked") private void parse_version_1_pAE(Map pae_obj) { // assume indices are with respect to range defined by _refSeq on the @@ -145,7 +177,6 @@ public class PAEContactMatrix implements ContactMatrixI { return -1; } - // TODO Auto-generated method stub return elements[_column][column]; } }); -- 1.7.10.2