@@ -118,6 +118,47 @@ public static JSONObject buildReverseTranslate(
118118 }
119119
120120
121+ /**
122+ *
123+ * @param designSequences
124+ * @param bAutoAnnotate
125+ * @param strategy
126+ * @param codonUsageTable
127+ * @param outputFormat
128+ *
129+ * @return
130+ *
131+ * @throws BOOSTClientException
132+ * @throws JSONException
133+ * @throws UnsupportedEncodingException
134+ * @throws SBOLConversionException
135+ */
136+ public static JSONObject buildCodonJuggle (
137+ final SBOLDocument designSequences , boolean bAutoAnnotate ,
138+ Strategy strategy , final String codonUsageTable ,
139+ final FileFormat outputFormat )
140+ throws BOOSTClientException , JSONException , UnsupportedEncodingException , SBOLConversionException {
141+
142+ // write the SBOLDocument to a String
143+ try (
144+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
145+ ) {
146+
147+ SBOLWriter .write (designSequences , outputStream );
148+ String designDoc = outputStream .toString ("UTF-8" );
149+
150+ // put its content into the JSON object
151+ if (designDoc != null && !designDoc .isEmpty ()) {
152+ return buildCodonJuggle (designDoc , bAutoAnnotate , strategy , codonUsageTable , outputFormat );
153+ }
154+
155+ } catch (Exception e ) {
156+ throw new BOOSTClientException (e .getMessage ());
157+ }
158+
159+ return (JSONObject )null ;
160+
161+ }
121162 /**
122163 *
123164 * @param designSequences
@@ -131,7 +172,7 @@ public static JSONObject buildReverseTranslate(
131172 * @throws JSONException
132173 */
133174 public static JSONObject buildCodonJuggle (
134- final SBOLDocument designSequences , boolean bAutoAnnotate ,
175+ final String sequenceFileContent , boolean bAutoAnnotate ,
135176 Strategy strategy , final String codonUsageTable ,
136177 final FileFormat outputFormat )
137178 throws BOOSTClientException , JSONException , UnsupportedEncodingException , SBOLConversionException {
@@ -151,7 +192,7 @@ public static JSONObject buildCodonJuggle(
151192
152193 // sequence information
153194 reverseTranslateData .put (JSONKeys .SEQUENCE_INFORMATION ,
154- RequestBuilder .buildSequenceData (designSequences , SequenceType .DNA , bAutoAnnotate ));
195+ RequestBuilder .buildSequenceData (sequenceFileContent , SequenceType .DNA , bAutoAnnotate ));
155196
156197 // modification information
157198 reverseTranslateData .put (JSONKeys .MODIFICATION_INFORMATION ,
@@ -447,6 +488,11 @@ public static JSONObject buildJobInformation(
447488 return jobInformation ;
448489 }
449490
491+ public static JSONObject buildSequenceData (final SBOLDocument designSequences , SequenceType type ,
492+ boolean bAutoAnnotate )
493+ throws BOOSTClientException , SBOLConversionException , UnsupportedEncodingException {
494+ return buildSequenceData (designSequences , type , bAutoAnnotate );
495+ }
450496 /**
451497 *
452498 * @param filename
@@ -458,31 +504,14 @@ public static JSONObject buildJobInformation(
458504 * @throws UnsupportedEncodingException
459505 * @throws IOException
460506 */
461- public static JSONObject buildSequenceData (final SBOLDocument designSequences , SequenceType type , boolean bAutoAnnotate )
507+ public static JSONObject buildSequenceData (final String sequenceFileContent , SequenceType type , boolean bAutoAnnotate )
462508 throws BOOSTClientException , SBOLConversionException , UnsupportedEncodingException {
463509
464510 // sequence information
465511 JSONObject sequenceData = new JSONObject ();
466512
467- // write the SBOLDocument to a String
468- try (
469- ByteArrayOutputStream outputStream = new ByteArrayOutputStream ();
470- ) {
471-
472- SBOLWriter .write (designSequences , outputStream );
473- String designDoc = outputStream .toString ("UTF-8" );
474-
475- System .out .println (designDoc );
476-
477- // put its content into the JSON object
478- if (designDoc != null && !designDoc .isEmpty ()) {
479- sequenceData .put (JSONKeys .TEXT , designDoc );
480- }
481-
482- } catch (Exception e ) {
483- throw new BOOSTClientException (e .getMessage ());
484- }
485-
513+ sequenceData .put (JSONKeys .TEXT , sequenceFileContent );
514+
486515 // sequence type
487516 JSONArray types = new JSONArray ();
488517 types .put (type );
0 commit comments