11package gov .doe .jgi .boost .client ;
22
33import java .io .IOException ;
4+ import java .io .UnsupportedEncodingException ;
45
56import javax .ws .rs .core .Response ;
7+
8+ import org .json .JSONException ;
69import org .json .JSONObject ;
10+ import org .sbolstandard .core2 .SBOLConversionException ;
11+ import org .sbolstandard .core2 .SBOLDocument ;
12+ import org .sbolstandard .core2 .SBOLReader ;
13+ import org .sbolstandard .core2 .SBOLValidationException ;
14+
15+ import gov .doe .jgi .boost .client .constants .BOOSTConstants ;
716import gov .doe .jgi .boost .client .constants .BOOSTResources ;
817import gov .doe .jgi .boost .client .constants .JSONKeys ;
918import gov .doe .jgi .boost .enums .FileFormat ;
@@ -129,37 +138,98 @@ public String getToken() {
129138 }
130139
131140 /**
132- * The reverseTranslate method invokes BOOT 's reverse-translate functionality.
141+ * The reverseTranslate method invokes BOOST 's reverse-translate functionality.
133142 *
134- * @param filenameSequences ... the name of the file that contains the input sequences
143+ * @param sequencesFilename ... the name of the file that contains the input sequences
135144 * @param strategy ... the codon selection strategy
136145 * @param filenameCodonUsageTable ... the name of the file that contains the codon usage table
137146 * @param outputFormat ... the desired output format
138147 *
139148 * @throws BOOSTClientException
140149 * @throws IOException
150+ * @throws SBOLConversionException
151+ * @throws SBOLValidationException
141152 * @throws BOOSTAPIsException
142153 */
143154 public String reverseTranslate (
144- final String filenameSequences ,
155+ final String sequencesFilename ,
145156 Strategy strategy , final String filenameCodonUsageTable ,
146157 final FileFormat outputFormat )
147- throws BOOSTClientException , BOOSTBackEndException , IOException {
158+ throws BOOSTClientException , BOOSTBackEndException , IOException ,
159+ SBOLValidationException , SBOLConversionException {
160+
161+ // verify for filename
162+ ParameterValueVerifier .verifyFilename (BOOSTConstants .INPUT_FILENAME , sequencesFilename );
163+
164+ // read the file as SBOLDocument
165+ SBOLDocument document = SBOLReader .read (sequencesFilename );
166+ return this .reverseTranslate (document , strategy , filenameCodonUsageTable , outputFormat );
167+ }
168+
169+ /**
170+ * The reverseTranslate method invokes BOOST's reverse-translate functionality.
171+ *
172+ * @param designSequences ... sbol document that contains the input sequences
173+ * @param strategy ... the codon selection strategy
174+ * @param filenameCodonUsageTable ... the name of the file that contains the codon usage table
175+ * @param outputFormat ... the desired output format
176+ *
177+ * @throws BOOSTClientException
178+ * @throws IOException
179+ * @throws JSONException
180+ * @throws SBOLConversionException
181+ * @throws BOOSTAPIsException
182+ */
183+ public String reverseTranslate (
184+ final SBOLDocument designSequences ,
185+ Strategy strategy , final String filenameCodonUsageTable ,
186+ final FileFormat outputFormat )
187+ throws BOOSTClientException , BOOSTBackEndException , IOException ,
188+ JSONException , SBOLConversionException {
148189
149190 // construct the request's JSON object
150191 JSONObject requestData = RequestBuilder .buildReverseTranslate (
151- filenameSequences , strategy , filenameCodonUsageTable , outputFormat );
152-
153- System .out .println (requestData .toString (4 ));
192+ designSequences , strategy , filenameCodonUsageTable , outputFormat );
154193
155194 return this .submitJob (requestData );
195+ }
196+
197+ /**
198+ * The codonJuggle method invokes BOOST's codon-juggling functionality.
199+ *
200+ * @param sequencesFilename ... the name of the file that contains the input sequences
201+ * @param bAutoAnnotate ... true ... all sequences exclusively 5'-3' protein coding sequences (is only considered
202+ * when the sequences don't have feature annotations, e.g. FASTA or CSV)
203+ * @param strategy ... the codon replacement strategy
204+ * @param filenameCodonUsageTable ... the name of the file that contains the codon usage table
205+ * @param outputFormat ... the desired output format
206+ *
207+ * @throws BOOSTClientException
208+ * @throws IOException
209+ * @throws SBOLConversionException
210+ * @throws SBOLValidationException
211+ * @throws BOOSTAPIsException
212+ */
213+ public String codonJuggle (
214+ final String sequencesFilename , boolean bAutoAnnotate ,
215+ Strategy strategy , final String filenameCodonUsageTable ,
216+ final FileFormat outputFormat )
217+ throws BOOSTClientException , BOOSTBackEndException , IOException ,
218+ SBOLValidationException , SBOLConversionException {
219+
220+ // verify for filename
221+ ParameterValueVerifier .verifyFilename (BOOSTConstants .INPUT_FILENAME , sequencesFilename );
156222
223+ // read the file as SBOLDocument
224+ SBOLDocument document = SBOLReader .read (sequencesFilename );
225+ return this .codonJuggle (document , bAutoAnnotate , strategy , filenameCodonUsageTable , outputFormat );
157226 }
158227
228+
159229 /**
160230 * The codonJuggle method invokes BOOST's codon-juggling functionality.
161231 *
162- * @param filenameSequences ... the name of the file that contains the input sequences
232+ * @param designSequences ... the sbol document that contains the input sequences
163233 * @param bAutoAnnotate ... true ... all sequences exclusively 5'-3' protein coding sequences (is only considered
164234 * when the sequences don't have feature annotations, e.g. FASTA or CSV)
165235 * @param strategy ... the codon replacement strategy
@@ -168,17 +238,20 @@ public String reverseTranslate(
168238 *
169239 * @throws BOOSTClientException
170240 * @throws IOException
241+ * @throws SBOLConversionException
242+ * @throws JSONException
171243 * @throws BOOSTAPIsException
172244 */
173245 public String codonJuggle (
174- final String filenameSequences , boolean bAutoAnnotate ,
246+ final SBOLDocument designSequences , boolean bAutoAnnotate ,
175247 Strategy strategy , final String filenameCodonUsageTable ,
176248 final FileFormat outputFormat )
177- throws BOOSTClientException , BOOSTBackEndException , IOException {
249+ throws BOOSTClientException , BOOSTBackEndException , IOException ,
250+ JSONException , SBOLConversionException {
178251
179252 // construct the request's JSON object
180253 JSONObject requestData = RequestBuilder .buildCodonJuggle (
181- filenameSequences , bAutoAnnotate , strategy , filenameCodonUsageTable , outputFormat );
254+ designSequences , bAutoAnnotate , strategy , filenameCodonUsageTable , outputFormat );
182255
183256 return this .submitJob (requestData );
184257 }
@@ -187,21 +260,56 @@ public String codonJuggle(
187260 * The verify method submits a job to BOOST that verifies
188261 * sequences against DNA synthesis constraints.
189262 *
190- * @param codingSequence ... the name of the file that contains the sequences
263+ * @param sequencesFileName ... the name of the file that contains the sequences
264+ * @param constraintsFilename ... the name of the file that contains the DNA synthesis constraints
265+ * @param sequencePatternsFilename ... the name of the file that contains sequence patterns
266+ *
267+ * @return the UUID of the submitted job
268+ *
269+ * @throws BOOSTClientException
270+ * @throws SBOLConversionException
271+ * @throws SBOLValidationException
272+ * @throws BOOSTAPIsException
273+ *
274+ */
275+ public String dnaVarification (
276+ final String sequencesFileName ,
277+ Vendor vendor ,
278+ final String sequencePatternsFilename )
279+ throws BOOSTClientException , BOOSTBackEndException ,
280+ IOException , SBOLValidationException , SBOLConversionException {
281+
282+ // verify for filename
283+ ParameterValueVerifier .verifyFilename (BOOSTConstants .INPUT_FILENAME , sequencesFileName );
284+
285+ // read the file as SBOLDocument
286+ SBOLDocument document = SBOLReader .read (sequencesFileName );
287+ return this .dnaVarification (document , vendor , sequencePatternsFilename );
288+
289+ }
290+
291+ /**
292+ * The verify method submits a job to BOOST that verifies
293+ * sequences against DNA synthesis constraints.
294+ *
295+ * @param codingSequence ... the sbol document that contains the sequences
191296 * @param constraintsFilename ... the name of the file that contains the DNA synthesis constraints
192297 * @param sequencePatternsFilename ... the name of the file that contains sequence patterns
193298 *
194299 * @return the UUID of the submitted job
195300 *
196301 * @throws BOOSTClientException
302+ * @throws SBOLConversionException
303+ * @throws JSONException
197304 * @throws BOOSTAPIsException
198305 *
199306 */
200307 public String dnaVarification (
201- final String codingSequence ,
308+ final SBOLDocument codingSequence ,
202309 Vendor vendor ,
203310 final String sequencePatternsFilename )
204- throws BOOSTClientException , BOOSTBackEndException , IOException {
311+ throws BOOSTClientException , BOOSTBackEndException , IOException ,
312+ JSONException , SBOLConversionException {
205313
206314 // represent the request data in JSON and
207315 // submit it to BOOST's Job Queue Management System (JQMS)
@@ -215,11 +323,14 @@ public String dnaVarification(
215323 *
216324 * @throws BOOSTClientException
217325 * @throws BOOSTBackEndException
326+ * @throws SBOLConversionException
327+ * @throws IOException
328+ * @throws SBOLValidationException
218329 * @throws BOOSTAPIsException
219330 */
220331
221332 public String partition (
222- String codingSequence ,
333+ final String sequencesFilename ,
223334 String fivePrimeVectorOverlap ,
224335 String threePrimeVectorOverlap ,
225336 String minLengthBB ,
@@ -233,7 +344,37 @@ public String partition(
233344 String minPrimerLength ,
234345 String maxPrimerLength ,
235346 String maxPrimerTm )
236- throws BOOSTClientException , BOOSTBackEndException {
347+ throws BOOSTClientException , BOOSTBackEndException ,
348+ SBOLValidationException , IOException , SBOLConversionException {
349+
350+ // verify for filename
351+ ParameterValueVerifier .verifyFilename (BOOSTConstants .INPUT_FILENAME , sequencesFilename );
352+
353+ // read the file as SBOLDocument
354+ SBOLDocument document = SBOLReader .read (sequencesFilename );
355+ return this .partition (document , fivePrimeVectorOverlap , threePrimeVectorOverlap ,
356+ minLengthBB , maxLengthBB , minOverlapGC , optOverlapGC , maxOverlapGC , minOverlapLength ,
357+ optOverlapLength , maxOverlapLength , minPrimerLength , maxPrimerLength , maxPrimerTm );
358+ }
359+
360+
361+ public String partition (
362+ SBOLDocument codingSequence ,
363+ String fivePrimeVectorOverlap ,
364+ String threePrimeVectorOverlap ,
365+ String minLengthBB ,
366+ String maxLengthBB ,
367+ String minOverlapGC ,
368+ String optOverlapGC ,
369+ String maxOverlapGC ,
370+ String minOverlapLength ,
371+ String optOverlapLength ,
372+ String maxOverlapLength ,
373+ String minPrimerLength ,
374+ String maxPrimerLength ,
375+ String maxPrimerTm )
376+ throws BOOSTClientException , BOOSTBackEndException , JSONException ,
377+ UnsupportedEncodingException , SBOLConversionException {
237378
238379 // construct the request's JSON object
239380 JSONObject requestData = RequestBuilder .buildPartition (codingSequence , fivePrimeVectorOverlap ,
@@ -356,16 +497,64 @@ public JSONObject getJobReport(final String jobUUID)
356497 *
357498 * @throws BOOSTClientException
358499 * @throws BOOSTBackEndException
500+ * @throws SBOLConversionException
501+ * @throws IOException
502+ * @throws SBOLValidationException
503+ * @throws BOOSTAPIsException
504+ */
505+ public String polish (
506+ final String sequencesFilename ,
507+ boolean bCodingSequences ,
508+ Vendor vendor ,
509+ Strategy strategy ,
510+ final FileFormat outputFormat ,
511+ final String codonUsageTable )
512+ throws BOOSTClientException , BOOSTBackEndException ,
513+ SBOLValidationException , IOException , SBOLConversionException {
514+
515+ // verify for filename
516+ ParameterValueVerifier .verifyFilename (BOOSTConstants .INPUT_FILENAME , sequencesFilename );
517+
518+ // read the file as SBOLDocument
519+ SBOLDocument document = SBOLReader .read (sequencesFilename );
520+ return this .polish (document , bCodingSequences , vendor , strategy ,
521+ outputFormat , codonUsageTable );
522+ }
523+
524+
525+ /**
526+ * The polish() method verifies the sequences in a given file against the
527+ * gene synthesis constraints of a commercial synthesis vendor.
528+ * In case of violations, the polish() method modifies the coding regions
529+ * of the sequence using the specified codon replacement strategy.
530+ *
531+ * @param codingSequence ... the sbol file that contains the sequences
532+ * @param type ... the type of the sequences, i.e. DNA, RNA, Protein
533+ * @param bCodingSequences ... if the sequences are encoded in a format that does not
534+ * support sequence feature annotations and if bCoding sequences is set to true,
535+ * then are all sequences are treated as coding sequences. If the sequences are
536+ * encoded in a format that does support sequence feature annotations, then the
537+ * bCodingSequences flag is ignored.
538+ * @param vendor ... the name of commercial synthesis provider
539+ * @param strategy ... the codon replacement strategy
540+ * @param codonUsageTableFilename ... the name of the file that contains the codon
541+ * usage table
542+ *
543+ * @throws BOOSTClientException
544+ * @throws BOOSTBackEndException
545+ * @throws SBOLConversionException
546+ * @throws UnsupportedEncodingException
547+ * @throws JSONException
359548 * @throws BOOSTAPIsException
360549 */
361550 public String polish (
362- final String codingSequence ,
551+ final SBOLDocument codingSequence ,
363552 boolean bCodingSequences ,
364553 Vendor vendor ,
365554 Strategy strategy ,
366555 final FileFormat outputFormat ,
367556 final String codonUsageTable )
368- throws BOOSTClientException , BOOSTBackEndException {
557+ throws BOOSTClientException , BOOSTBackEndException , JSONException , UnsupportedEncodingException , SBOLConversionException {
369558
370559 // construct the request's JSON object
371560 JSONObject requestData = RequestBuilder .buildPolish ( codingSequence ,
0 commit comments