From: tcofoegbu Date: Thu, 10 Mar 2016 15:17:37 +0000 (+0000) Subject: JAL-2025 added code to stanitise query for structure by sequence name which contains... X-Git-Tag: Release_2_10_0~302 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=e4c2aac5d24da467eba0fcb27fe2d67f090a99bf;p=jalview.git JAL-2025 added code to stanitise query for structure by sequence name which contains special characters --- diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 34c9b79..d313002 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -43,6 +43,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -301,6 +302,7 @@ public class StructureChooser extends GStructureChooser implements if (!isPDBRefsFound && !isUniProtRefsFound) { String seqName = seq.getName(); + seqName = sanitizeSeqName(seqName); String[] names = seqName.toLowerCase().split("\\|"); for (String name : names) { @@ -328,6 +330,21 @@ public class StructureChooser extends GStructureChooser implements } /** + * Remove the following special characters from input string +, -, &, |, !, (, + * ), {, }, [, ], ^, ", ~, *, ?, :, \ + * + * @param seqName + * @return + */ + private static String sanitizeSeqName(String seqName) + { + Objects.requireNonNull(seqName); + return seqName.replaceAll("\\[\\d*\\]", "") + .replaceAll("[^\\dA-Za-z ]", "").replaceAll("\\s+", "+"); + } + + + /** * Ensures sequence ref names are not less than 3 characters and does not * contain a database name *