X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Futil%2FDBRefUtils.java;fp=src%2Fjalview%2Futil%2FDBRefUtils.java;h=197261ac154716b46c73f097d2aa58b160e51f01;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=fb54bbabaad9e6585e5cee0eb3e20f8a91e8c3a2;hpb=d4ec118f86b5c9dee801e743c46aaacc7bb521d1;p=jalview.git diff --git a/src/jalview/util/DBRefUtils.java b/src/jalview/util/DBRefUtils.java index fb54bba..197261a 100755 --- a/src/jalview/util/DBRefUtils.java +++ b/src/jalview/util/DBRefUtils.java @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import com.stevesoft.pat.Regex; @@ -96,14 +95,14 @@ public class DBRefUtils } // BH TODO (what?) - HashSet srcs = new HashSet(); + HashSet srcs = new HashSet<>(); for (String src : sources) { srcs.add(src.toUpperCase()); } int nrefs = dbrefs.size(); - List res = new ArrayList(); + List res = new ArrayList<>(); for (int ib = 0; ib < nrefs; ib++) { DBRefEntry dbr = dbrefs.get(ib); @@ -217,7 +216,7 @@ public class DBRefUtils * @return */ public static List searchRefs(List refs, String accId) { - List rfs = new ArrayList(); + List rfs = new ArrayList<>(); if (refs == null || accId == null) { return rfs; } @@ -243,7 +242,7 @@ public class DBRefUtils * @return */ static List searchRefs(List refs, DBRefEntry entry, DbRefComp comparator, int mode) { - List rfs = new ArrayList(); + List rfs = new ArrayList<>(); if (refs == null || entry == null) { return rfs; } @@ -450,6 +449,14 @@ public class DBRefUtils return matches; } + private static Regex PARSE_REGEX; + + private static Regex getParseRegex() + { + return (PARSE_REGEX == null ? PARSE_REGEX = Platform.newRegex( + "([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)", null) + : PARSE_REGEX); + } /** * Parses a DBRefEntry and adds it to the sequence, also a PDBEntry if the * database is PDB. @@ -471,7 +478,7 @@ public class DBRefUtils /* * Check for PFAM style stockhom PDB accession id citation e.g. "1WRI A; 7-80;" */ - Regex r = new com.stevesoft.pat.Regex("([0-9][0-9A-Za-z]{3})\\s*(.?)\\s*;\\s*([0-9]+)-([0-9]+)"); + Regex r = getParseRegex(); if (r.search(acn.trim())) { String pdbid = r.stringMatched(1); String chaincode = r.stringMatched(2); @@ -558,7 +565,7 @@ public class DBRefUtils * @return */ public static List searchRefsForSource(List dbRefs, String source) { - List matches = new ArrayList(); + List matches = new ArrayList<>(); if (dbRefs != null && source != null) { for (DBRefEntry dbref : dbRefs) { if (source.equalsIgnoreCase(dbref.getSource())) { @@ -621,7 +628,9 @@ public class DBRefUtils bsSelect.set(0, dbrefs.size()); if (!selectRefsBS(dbrefs, isProtein ? DBRefSource.PROTEIN_MASK : DBRefSource.DNA_CODING_MASK, bsSelect)) - return; + { + return; + } // selfs.addAll(selfArray); // } @@ -631,7 +640,9 @@ public class DBRefUtils DBRefEntry p = pr.get(ip); for (int i = bsSelect.nextSetBit(0); i >= 0; i = bsSelect.nextSetBit(i + 1)) { if (dbrefs.get(i) == p) - bsSelect.clear(i); + { + bsSelect.clear(i); + } } // while (selfs.contains(p)) // { @@ -655,7 +666,9 @@ public class DBRefUtils // TODO: promote transcript refs ?? } if (keys == 0 || !selectRefsBS(dbrefs, keys, bsSelect)) - return; + { + return; + } // if (candidates != null) { for (int ic = bsSelect.nextSetBit(0); ic >= 0; ic = bsSelect.nextSetBit(ic + 1))