From 9527f18e0ba0625e0e4fd8e7bcb41369812dbbe2 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 18 Aug 2020 15:32:00 +0100 Subject: [PATCH] JAL-1260 refactored multi-line qualifier separators --- src/jalview/io/FlatFile.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jalview/io/FlatFile.java b/src/jalview/io/FlatFile.java index 01ce085..55fdd37 100644 --- a/src/jalview/io/FlatFile.java +++ b/src/jalview/io/FlatFile.java @@ -215,7 +215,7 @@ public abstract class FlatFile extends AlignFile */ CdsData data = new CdsData(); StringBuilder sb = new StringBuilder().append(location); - line = parseFeatureQualifier(sb, LOCATION); + line = parseFeatureQualifier(sb, false); data.cdsLocation = sb.toString(); while (line != null) @@ -250,7 +250,8 @@ public abstract class FlatFile extends AlignFile String value = line.substring(eqPos + 1); value = removeQuotes(value); sb = new StringBuilder().append(value); - line = parseFeatureQualifier(sb, qualifier); + boolean asText = !"translation".equals(qualifier); + line = parseFeatureQualifier(sb, asText); String featureValue = sb.toString(); if ("protein_id".equals(qualifier)) @@ -638,11 +639,11 @@ public abstract class FlatFile extends AlignFile * * @param sb * a string buffer primed with the first line of the value - * @param qualifierName + * @param asText * @return * @throws IOException */ - String parseFeatureQualifier(StringBuilder sb, String qualifierName) + String parseFeatureQualifier(StringBuilder sb, boolean asText) throws IOException { String line; @@ -665,11 +666,10 @@ public abstract class FlatFile extends AlignFile } /* - * heuristic rule: most multi-line value (e.g. /product) are text, - * so add a space for word boundary at a new line; not for translation + * if text (e.g. /product), add a word separator for a new line, + * else (e.g. /translation) don't */ - if (!"translation".equals(qualifierName) - && !LOCATION.equals(qualifierName)) + if (asText) { sb.append(" "); } -- 1.7.10.2