Skip to content

Commit f27305e

Browse files
jamesmorrisjamesmorris
authored andcommitted
maintain quotes around feature qualifiers if they are present
1 parent 21ec595 commit f27305e

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

biojava-core/src/main/java/org/biojava/nbio/core/sequence/io/GenbankSequenceParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,12 @@ private void parseFeatureTag(List<String[]> section) {
200200
if (gbFeature == null) {
201201
throw new ParserException("Malformed GenBank file: found a qualifier without feature.");
202202
}
203+
Boolean needsQuotes = false;
203204
key = key.substring(1); // strip leading slash
204205
val = val.replaceAll("\\s*[\\n\\r]+\\s*", " ").trim();
205206
if (val.endsWith("\"")) {
206207
val = val.substring(1, val.length() - 1); // strip quotes
208+
needsQuotes = true; // as the value has quotes then set that it needs quotes when written back out
207209
}
208210
// parameter on old feature
209211
if (key.equals("db_xref")) {
@@ -221,17 +223,17 @@ private void parseFeatureTag(List<String[]> section) {
221223
throw new ParserException("Bad dbxref");
222224
}
223225
} else if (key.equalsIgnoreCase("organism")) {
224-
Qualifier q = new Qualifier(key, val.replace('\n', ' '));
226+
Qualifier q = new Qualifier(key, val.replace('\n', ' '), needsQuotes);
225227
gbFeature.addQualifier(key, q);
226228
} else {
227229
if (key.equalsIgnoreCase("translation") || key.equals("anticodon")
228230
|| key.equals("transl_except")) {
229231
// strip spaces from sequence
230232
val = val.replaceAll("\\s+", "");
231-
Qualifier q = new Qualifier(key, val);
233+
Qualifier q = new Qualifier(key, val, needsQuotes);
232234
gbFeature.addQualifier(key, q);
233235
} else {
234-
Qualifier q = new Qualifier(key, val);
236+
Qualifier q = new Qualifier(key, val, needsQuotes);
235237
gbFeature.addQualifier(key, q);
236238
}
237239
}

0 commit comments

Comments
 (0)