X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2Fstructurechooser%2FTDBResultAnalyser.java;h=fcc1ffee1c7c6c8935ab9138f63279c9c8182b35;hb=a3f8f05c73d08184254a8751c99824cfd126c4be;hp=ffac9c40e67cdfa938564f548b2649d76e9bbc53;hpb=b41e048ca5217c3cd7cdff5ece0f20d885ce0a80;p=jalview.git diff --git a/src/jalview/gui/structurechooser/TDBResultAnalyser.java b/src/jalview/gui/structurechooser/TDBResultAnalyser.java index ffac9c4..fcc1ffe 100644 --- a/src/jalview/gui/structurechooser/TDBResultAnalyser.java +++ b/src/jalview/gui/structurechooser/TDBResultAnalyser.java @@ -1,3 +1,23 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.gui.structurechooser; import java.util.ArrayList; @@ -7,6 +27,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Locale; import jalview.datamodel.SequenceI; import jalview.fts.api.FTSData; @@ -23,8 +44,8 @@ public class TDBResultAnalyser */ private static List EXP_CATEGORIES = Arrays .asList(new String[] - { "EXPERIMENTALLY DETERMINED", "DEEP-LEARNING", "TEMPLATE-BASED", - "AB-INITIO", "CONFORMATIONAL ENSEMBLE" }); + { "EXPERIMENTALLY DETERMINED", "DEEP-LEARNING", "AB-INITIO", + "TEMPLATE-BASED", "CONFORMATIONAL ENSEMBLE" }); private SequenceI seq; @@ -85,7 +106,7 @@ public class TDBResultAnalyser { return 0; } - String upper_cat = cat.toUpperCase(); + String upper_cat = cat.toUpperCase(Locale.ROOT); int idx = EXP_CATEGORIES.indexOf(upper_cat); if (idx == -1) { @@ -109,18 +130,22 @@ public class TDBResultAnalyser // ignore anything outside the sequence region for (FTSData row : collectedResults) { - int up_s = (Integer) row.getSummaryData()[idx_ups]; - int up_e = (Integer) row.getSummaryData()[idx_upe]; - String provider = (String) row.getSummaryData()[idx_mprov]; - String mcat = (String) row.getSummaryData()[idx_mcat]; - // this makes sure all new categories are in the score array. - int scorecat = scoreCategory(mcat); - if (sourceFilter == null || sourceFilter.equals(provider)) + if (row.getSummaryData() != null + && row.getSummaryData()[idx_ups] != null) { - if (seq == row.getSummaryData()[0] && up_e > seq.getStart() - && up_s < seq.getEnd()) + int up_s = (Integer) row.getSummaryData()[idx_ups]; + int up_e = (Integer) row.getSummaryData()[idx_upe]; + String provider = (String) row.getSummaryData()[idx_mprov]; + String mcat = (String) row.getSummaryData()[idx_mcat]; + // this makes sure all new categories are in the score array. + int scorecat = scoreCategory(mcat); + if (sourceFilter == null || sourceFilter.equals(provider)) { - filteredResponse.add(row); + if (seq == row.getSummaryData()[0] && up_e > seq.getStart() + && up_s < seq.getEnd()) + { + filteredResponse.add(row); + } } } } @@ -136,12 +161,13 @@ public class TDBResultAnalyser int o1_s = (Integer) o1data[idx_ups]; int o1_e = (Integer) o1data[idx_upe]; int o1_cat = scoreCategory((String) o1data[idx_mcat]); - String o1_prov= ((String) o1data[idx_mprov]).toUpperCase(); + String o1_prov = ((String) o1data[idx_mprov]) + .toUpperCase(Locale.ROOT); int o2_s = (Integer) o2data[idx_ups]; int o2_e = (Integer) o2data[idx_upe]; int o2_cat = scoreCategory((String) o2data[idx_mcat]); - String o2_prov= ((String) o2data[idx_mprov]).toUpperCase(); - + String o2_prov = ((String) o2data[idx_mprov]) + .toUpperCase(Locale.ROOT); if (o1_cat == o2_cat) { @@ -151,34 +177,45 @@ public class TDBResultAnalyser int o2_xtent = o2_e - o2_s; if (o1_xtent == o2_xtent) { + // EXPERIMENTAL DATA ALWAYS TRUMPS MODELS if (o1_cat == scoreCategory(EXP_CATEGORIES.get(0))) { - if (o1_prov.equals(o2_prov)) { - if ("PDBE".equals(o1_prov)) { - if (eitherNull(idx_resol,o1data,o2data)) + if (o1_prov.equals(o2_prov)) + { + if ("PDBE".equals(o1_prov)) + { + if (eitherNull(idx_resol, o1data, o2data)) { - return nonNullFirst(idx_resol,o1data,o2data); + return nonNullFirst(idx_resol, o1data, o2data); } - // experimental structures, so rank on quality - double o1_res = (Double) o1data[idx_resol]; - double o2_res = (Double) o2data[idx_resol]; - return (o2_res < o1_res) ? 1 : (o2_res == o1_res) ? 0 : -1; - } else { - return 0; // no change in order + // experimental structures, so rank on quality + double o1_res = (Double) o1data[idx_resol]; + double o2_res = (Double) o2data[idx_resol]; + return (o2_res < o1_res) ? 1 + : (o2_res == o1_res) ? 0 : -1; + } + else + { + return 0; // no change in order + } + } + else + { + // PDBe always ranked above all other experimentally + // determined categories + return "PDBE".equals(o1_prov) ? -1 + : "PDBE".equals(o2_prov) ? 1 : 0; } - } else { - // PDBe always ranked above all other experimentally determined categories - return "PDBE".equals(o1_prov) ? -1 : "PDBE".equals(o2_prov) ? 1 : 0; - } } else { - if (eitherNull(idx_mqual,o1data, o2data)) { + if (eitherNull(idx_mqual, o1data, o2data)) + { return nonNullFirst(idx_mqual, o1data, o2data); } // models, so rank on qmean - b - float o1_mq = (Float) o1data[idx_mqual]; - float o2_mq = (Float) o2data[idx_mqual]; + double o1_mq = (Double) o1data[idx_mqual]; + double o2_mq = (Double) o2data[idx_mqual]; return (o2_mq < o1_mq) ? 1 : (o2_mq == o1_mq) ? 0 : -1; } } @@ -194,6 +231,12 @@ public class TDBResultAnalyser } else { + // if both are not experimental, then favour alphafold + if (o2_cat > 0 && o1_cat > 0) + { + return "ALPHAFOLD DB".equals(o1_prov) ? -1 + : "ALPHAFOLD DB".equals(o2_prov) ? 1 : 0; + } return o2_cat - o1_cat; } } @@ -201,13 +244,14 @@ public class TDBResultAnalyser private int nonNullFirst(int idx_resol, Object[] o1data, Object[] o2data) { - return o1data[idx_resol] == o2data[idx_resol] ? 0: o1data[idx_resol] != null ? -1 : 1; + return o1data[idx_resol] == o2data[idx_resol] ? 0 + : o1data[idx_resol] != null ? -1 : 1; } private boolean eitherNull(int idx_resol, Object[] o1data, Object[] o2data) { - return (o1data[idx_resol] == null || o2data[idx_resol]==null); + return (o1data[idx_resol] == null || o2data[idx_resol] == null); } @Override @@ -233,6 +277,8 @@ public class TDBResultAnalyser BitSet cover = new BitSet(); cover.set(seq.getStart(), seq.getEnd()); // walk down the list of structures, selecting some to add to selected + // TODO: could do simple DP - double loop to select largest number of + // structures covering largest number of sites for (FTSData structure : filteredStructures) { Object[] odata = structure.getSummaryData(); @@ -250,6 +296,10 @@ public class TDBResultAnalyser cover.andNot(scover); } } + if (selected.size() == 0) + { + return selected; + } // final step is to sort on length - this might help the superposition // process Collections.sort(selected, new Comparator()