@@ -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