From e4c2aac5d24da467eba0fcb27fe2d67f090a99bf Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 10 Mar 2016 15:17:37 +0000 Subject: [PATCH] JAL-2025 added code to stanitise query for structure by sequence name which contains special characters --- src/jalview/gui/StructureChooser.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 * -- 1.7.10.2