Skip to content

Commit 02710b0

Browse files
authored
Merge pull request #13 from eoberortner/GSoC18
revert Pull request hash code- b4a6fb2
2 parents 17bae8a + 786a87c commit 02710b0

13 files changed

Lines changed: 722 additions & 59 deletions

File tree

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ by providing a method for each functionality of the BOOST REST API.
2121

2222
As a first step, you have to instantiate the BOOSTClient class using one of the following alternatives:
2323

24-
* providing your BOOST username and password.
24+
* providing your BOOST username and password.You can provide these in LoginCredentials class.
2525

2626
```
27-
BOOSTClient client = new BOOSTClient("your-username", "your-password");
27+
BOOSTClient client = new BOOSTClient(LoginCredentials.mUserName, LoginCredentials.mPassword);
2828
```
2929

30-
* providing your BOOST JSON Web Token (JWT)
30+
* providing your BOOST JSON Web Token (JWT). You can provide your BOOST-JWT token in LoginCredentials class.
3131

3232
```
33-
BOOSTClient client = new BOOSTClient("your-BOOST-JWT");
33+
BOOSTClient client = new BOOSTClient(LoginCredentials.mJWT);
3434
```
3535

3636
### Supported methods of the BOOST Client
@@ -56,6 +56,27 @@ client.codonJuggle(
5656
FileFormat.GENBANK); // the desired output format
5757
```
5858

59+
* dnaVerification
60+
61+
```
62+
client.dnaVarification(
63+
"./data/dna.fasta", // a FASTA file containing the input sequence
64+
Vendor.GEN9 // vendor
65+
"./data/patterns.fasta"); // sequence patterns
66+
```
67+
68+
* polish
69+
70+
```
71+
client.polish(
72+
"./data/dna.fasta", // a FASTA file containing input sequence
73+
true, // encoding sequences support sequence feature annotations
74+
Vendor.JGI, // vendor
75+
Strategy.Balanced2Random, // codon selection strategy
76+
FileFormat.SBOL, // the desired output format
77+
"Saccharomyces cerevisiae"); // predefined host
78+
```
79+
5980
## Examples
6081

6182
An example of invoking every supported method is provided in the [DemoClient](https://github.com/eoberortner/BOOST-REST-Client/blob/master/src/test/java/gov/doe/jgi/boost/client/DemoClient.java)
@@ -70,4 +91,4 @@ Please contact ```eoberortner (at) lbl (dot) gov```
7091

7192

7293

73-
94+

src/main/java/gov/doe/jgi/boost/client/BOOSTClient.java

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import gov.doe.jgi.boost.client.constants.BOOSTResources;
1010
import gov.doe.jgi.boost.client.constants.JSONKeys;
1111
import gov.doe.jgi.boost.enums.FileFormat;
12+
import gov.doe.jgi.boost.enums.SequenceType;
1213
import gov.doe.jgi.boost.enums.Strategy;
14+
import gov.doe.jgi.boost.enums.Vendor;
1315
import gov.doe.jgi.boost.exception.BOOSTBackEndException;
1416
import gov.doe.jgi.boost.exception.BOOSTClientException;
1517

@@ -224,18 +226,49 @@ public String codonJuggle(
224226
*
225227
* @throws BOOSTClientException
226228
*/
227-
public String verify(
229+
public String dnaVarification(
228230
final String filenameSequences,
229-
final String constraintsFilename,
231+
Vendor vendor,
230232
final String sequencePatternsFilename)
231233
throws BOOSTClientException, BOOSTBackEndException, IOException {
232234

233235
// represent the request data in JSON and
234236
// submit it to BOOST's Job Queue Management System (JQMS)
235237
return submitJob(RequestBuilder.buildVerify(
236-
filenameSequences, constraintsFilename, sequencePatternsFilename));
238+
filenameSequences, vendor, sequencePatternsFilename));
237239
}
238240

241+
/**
242+
* The partition() method Partitioning of large DNA sequences into synthesizable
243+
* building blocks with partial overlaps for an efficient assembly.
244+
*
245+
* @throws BOOSTClientException
246+
* @throws BOOSTBackEndException
247+
*/
248+
249+
public String partition(
250+
String sequenceFileName,
251+
String fivePrimeVectorOverlap,
252+
String threePrimeVectorOverlap,
253+
String minLengthBB,
254+
String maxLengthBB,
255+
String minOverlapGC,
256+
String optOverlapGC,
257+
String maxOverlapGC,
258+
String minOverlapLength,
259+
String optOverlapLength,
260+
String maxOverlapLength)
261+
throws BOOSTClientException, BOOSTBackEndException {
262+
263+
// construct the request's JSON object
264+
JSONObject requestData = RequestBuilder.buildPartation(sequenceFileName, fivePrimeVectorOverlap,
265+
threePrimeVectorOverlap, minLengthBB, maxLengthBB, minOverlapGC, optOverlapGC, maxOverlapGC,
266+
minOverlapLength, optOverlapLength, maxOverlapLength);
267+
268+
return submitJob(requestData);
269+
}
270+
271+
239272
/**
240273
* The submitJob method submits a job to the BOOST back-end and returns
241274
* the UUID (as String) of the submitted job.
@@ -383,33 +416,48 @@ public JSONObject getJobReport(final String jobUUID)
383416
// throw new BOOSTClientException(e.getLocalizedMessage());
384417
// }
385418
// }
386-
//
387-
//
388-
// /**
389-
// * The polish() method verifies the sequences in a given file against the
390-
// * gene synthesis constraints of a commercial synthesis vendor.
391-
// * In case of violations, the polish() method modifies the coding regions
392-
// * of the sequence using the specified codon replacement strategy.
393-
// *
394-
// * @param sequencesFilename ... the name of the file that contains the sequences
395-
// * @param type ... the type of the sequences, i.e. DNA, RNA, Protein
396-
// * @param bCodingSequences ... if the sequences are encoded in a format that does not
397-
// * support sequence feature annotations and if bCoding sequences is set to true,
398-
// * then are all sequences are treated as coding sequences. If the sequences are
399-
// * encoded in a format that does support sequence feature annotations, then the
400-
// * bCodingSequences flag is ignored.
401-
// * @param vendor ... the name of commercial synthesis provider
402-
// * @param strategy ... the codon replacement strategy
403-
// * @param codonUsageTableFilename ... the name of the file that contains the codon
404-
// * usage table
405-
// *
406-
// * @throws BOOSTClientException
407-
// */
408-
// public void polish(final String sequencesFilename, SequenceType type, boolean bCodingSequences,
409-
// Vendor vendor, Strategy strategy, final String codonUsageTableFilename)
410-
// throws BOOSTClientException {
411-
//
412-
// // check if the user did a login previously
419+
420+
421+
/**
422+
* The polish() method verifies the sequences in a given file against the
423+
* gene synthesis constraints of a commercial synthesis vendor.
424+
* In case of violations, the polish() method modifies the coding regions
425+
* of the sequence using the specified codon replacement strategy.
426+
*
427+
* @param sequencesFilename ... the name of the file that contains the sequences
428+
* @param type ... the type of the sequences, i.e. DNA, RNA, Protein
429+
* @param bCodingSequences ... if the sequences are encoded in a format that does not
430+
* support sequence feature annotations and if bCoding sequences is set to true,
431+
* then are all sequences are treated as coding sequences. If the sequences are
432+
* encoded in a format that does support sequence feature annotations, then the
433+
* bCodingSequences flag is ignored.
434+
* @param vendor ... the name of commercial synthesis provider
435+
* @param strategy ... the codon replacement strategy
436+
* @param codonUsageTableFilename ... the name of the file that contains the codon
437+
* usage table
438+
*
439+
* @throws BOOSTClientException
440+
* @throws BOOSTBackEndException
441+
*/
442+
public String polish(
443+
final String sequencesFilename,
444+
boolean bCodingSequences,
445+
Vendor vendor,
446+
Strategy strategy,
447+
final FileFormat outputFormat,
448+
final String codonUsageTable)
449+
throws BOOSTClientException, BOOSTBackEndException {
450+
451+
// construct the request's JSON object
452+
JSONObject requestData = RequestBuilder.buildPolish( sequencesFilename,
453+
bCodingSequences, vendor, strategy, outputFormat, codonUsageTable);
454+
455+
return submitJob(requestData);
456+
457+
}
458+
459+
460+
// check if the user did a login previously
413461
// if(null == token) {
414462
// throw new BOOSTClientException("You must authenticate first!");
415463
// }

src/main/java/gov/doe/jgi/boost/client/RequestBuilder.java

Lines changed: 162 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,14 @@ public static JSONObject buildCodonJuggle(
165165
*/
166166
public static JSONObject buildVerify(
167167
final String filenameSequences,
168-
final String constraintsFilename,
168+
Vendor vendor,
169169
final String sequencePatternsFilename)
170170
throws BOOSTClientException, IOException {
171171

172172
//---------------------------------
173173
// verify the given values
174174
ParameterValueVerifier.verifyFilename(JSONKeys.SEQUENCE_INFORMATION, filenameSequences);
175-
ParameterValueVerifier.verifyFilename(JSONKeys.CONSTRAINTS_INFORMATION, constraintsFilename);
175+
ParameterValueVerifier.verifyNull(BOOSTConstants.VENDOR, vendor);
176176
// the sequence patterns filename is optional
177177
if(null != sequencePatternsFilename && !sequencePatternsFilename.trim().isEmpty()) {
178178
ParameterValueVerifier.verifyFilename(JSONKeys.PATTERN_INFORMATION, sequencePatternsFilename);
@@ -202,14 +202,172 @@ public static JSONObject buildVerify(
202202

203203
//---------------------------------
204204
// CONSTRAINTS
205-
requestData.put(JSONKeys.CONSTRAINTS_INFORMATION,
206-
RequestBuilder.buildConstraints(constraintsFilename));
205+
requestData.put(JSONKeys.VENDOR_NAME, vendor);
207206
//---------------------------------
208207

209208

210209
return requestData;
211210
}
212211

212+
213+
/**
214+
*
215+
* @param sequencesFilename ... the name of the file that contains the sequences
216+
* @param type ... the type of the sequences, i.e. DNA, RNA, Protein
217+
* @param bCodingSequences ... if the sequences are encoded in a format that does not
218+
* support sequence feature annotations and if bCoding sequences is set to true,
219+
* then are all sequences are treated as coding sequences. If the sequences are
220+
* encoded in a format that does support sequence feature annotations, then the
221+
* bCodingSequences flag is ignored.
222+
* @param vendor ... the name of commercial synthesis provider
223+
* @param strategy ... the codon replacement strategy
224+
* @param codonUsageTableFilename ... the name of the file that contains the codon
225+
* usage table
226+
*
227+
* @throws BOOSTClientException
228+
*/
229+
public static JSONObject buildPolish(
230+
final String sequencesFilename,
231+
boolean bCodingSequences,
232+
Vendor vendor,
233+
Strategy strategy,
234+
final FileFormat outputFormat,
235+
final String codonUsageTable)
236+
throws BOOSTClientException {
237+
238+
//-------------------------------------
239+
// verify the given values
240+
ParameterValueVerifier.verifyFilename(BOOSTConstants.INPUT_FILENAME, sequencesFilename);
241+
ParameterValueVerifier.verifyNull(BOOSTConstants.VENDOR, vendor);
242+
try {
243+
ParameterValueVerifier.verifyFilename(BOOSTConstants.CODON_USAGE_TABLE, codonUsageTable);
244+
} catch(Exception e) {}
245+
ParameterValueVerifier.verifyNull(BOOSTConstants.OUTPUT_FORMAT, outputFormat);
246+
ParameterValueVerifier.verifyNull(BOOSTConstants.STRATEGY, strategy);
247+
//----------------------------------------
248+
249+
JSONObject modifiedData = new JSONObject();
250+
251+
//-----------------------------------------
252+
//JOB INFORMATION
253+
modifiedData.put(JSONKeys.JOB_INFORMATION,
254+
RequestBuilder.buildJobInformation(BOOSTFunctions.POLISH));
255+
//-----------------------------------------
256+
257+
// sequence information
258+
modifiedData.put(JSONKeys.SEQUENCE_INFORMATION,
259+
RequestBuilder.buildSequenceData(sequencesFilename, SequenceType.DNA, bCodingSequences ));
260+
//-----------------------------------------
261+
262+
// constraints
263+
modifiedData.put(JSONKeys.VENDOR_NAME, vendor);
264+
//------------------------------------------
265+
266+
// modification information
267+
modifiedData.put(JSONKeys.MODIFICATION_INFORMATION,
268+
RequestBuilder.buildModificationData(strategy, codonUsageTable));
269+
//-------------------------------------------
270+
271+
// output information
272+
modifiedData.put(JSONKeys.OUTPUT_INFORMATION,
273+
RequestBuilder.buildOutputData(outputFormat));
274+
//-------------------------------------------------
275+
276+
277+
return modifiedData;
278+
}
279+
280+
/**
281+
* The buildPartation wraps all required information for
282+
* BOOST's dna partition functionality into a JSON representation
283+
*
284+
* @return a JSONObject that represents the input values
285+
*
286+
* @throws BOOSTClientException ... if any given value is NULL or any given String value is empty
287+
* */
288+
289+
public static JSONObject buildPartation(
290+
final String sequenceFileName,
291+
final String fivePrimeVectorOverlap,
292+
final String threePrimeVectorOverlap,
293+
String minLengthBB,
294+
String maxLengthBB,
295+
String minOverlapGC,
296+
String optOverlapGC,
297+
String maxOverlapGC,
298+
String minOverlapLength,
299+
String optOverlapLength,
300+
String maxOverlapLength)
301+
throws BOOSTClientException{
302+
303+
//verify the values
304+
ParameterValueVerifier.verifyFilename(BOOSTConstants.INPUT_FILENAME, sequenceFileName);
305+
ParameterValueVerifier.verifyValue(BOOSTConstants.FIVE_PRIME_VECTOR_OVERLAP, fivePrimeVectorOverlap);
306+
ParameterValueVerifier.verifyValue(BOOSTConstants.THREE_PRIME_VECTOR_OVERLAP, threePrimeVectorOverlap);
307+
ParameterValueVerifier.verifyValue(BOOSTConstants.MIN_BB_LENGTH, minLengthBB);
308+
ParameterValueVerifier.verifyValue(BOOSTConstants.MAX_BB_LENGTH, maxLengthBB);
309+
ParameterValueVerifier.verifyValue(BOOSTConstants.MIN_OVERLAP_GC, minOverlapGC);
310+
ParameterValueVerifier.verifyValue(BOOSTConstants.OPT_OVERLAP_GC, optOverlapGC);
311+
ParameterValueVerifier.verifyValue(BOOSTConstants.MAX_OVERLAP_GC, maxOverlapGC);
312+
ParameterValueVerifier.verifyValue(BOOSTConstants.MIN_OVERLAP_LENGTH, minOverlapGC);
313+
ParameterValueVerifier.verifyValue(BOOSTConstants.OPT_OVERLAP_LENGTH, optOverlapGC);
314+
ParameterValueVerifier.verifyValue(BOOSTConstants.MAX_OVERLAP_LENGTH, maxOverlapLength);
315+
316+
//----------------------------------------------
317+
318+
// build the JSON representation of the input values
319+
JSONObject partationData = new JSONObject();
320+
321+
//----------------------------------------------
322+
323+
324+
// JOB INFORMATION
325+
partationData.put(JSONKeys.JOB_INFORMATION,
326+
RequestBuilder.buildJobInformation(BOOSTFunctions.PARTITION));
327+
//----------------------------------------------
328+
329+
330+
// sequence information
331+
partationData.put(JSONKeys.SEQUENCE_INFORMATION,
332+
RequestBuilder.buildSequenceData(sequenceFileName, SequenceType.DNA, false));
333+
334+
// partition information
335+
partationData.put(JSONKeys.PARTITIONING_INFORMATION,
336+
RequestBuilder.buildPartitionData(sequenceFileName, fivePrimeVectorOverlap,
337+
threePrimeVectorOverlap, minLengthBB, maxLengthBB, minOverlapGC, optOverlapGC,
338+
maxOverlapGC, minOverlapLength, optOverlapLength, maxOverlapLength));
339+
340+
341+
return partationData;
342+
343+
}
344+
345+
private static JSONObject buildPartitionData(final String sequenceFileName,
346+
final String fivePrimeVectorOverlap, final String threePrimeVectorOverlap,
347+
String minLengthBB, String maxLengthBB, String minOverlapGC, String optOverlapGC,
348+
String maxOverlapGC, String minOverlapLength, String optOverlapLength, String maxOverlapLength){
349+
350+
JSONObject partationData = new JSONObject();
351+
//JSONObject subPartationData = new JSONObject();
352+
partationData.put(JSONKeys.FIVE_PRIME_VECTOR_OVERLAP, fivePrimeVectorOverlap);
353+
partationData.put(JSONKeys.THREE_PRIME_VECTOR_OVERLAP, threePrimeVectorOverlap);
354+
partationData.put(JSONKeys.MAX_BB_LENGTH, maxLengthBB);
355+
partationData.put(JSONKeys.MIN_BB_LENGTH, minLengthBB);
356+
partationData.put(JSONKeys.MAX_OVERLAP_GC, maxOverlapGC);
357+
partationData.put(JSONKeys.BATCH, "");
358+
partationData.put(JSONKeys.MIN_OVERLAP_GC, minOverlapGC);
359+
partationData.put(JSONKeys.MAX_OVERLAP_LENGTH, maxOverlapLength);
360+
partationData.put(JSONKeys.OPT_OVERLAP_GC, optOverlapGC);
361+
partationData.put(JSONKeys.OPT_OVERLAP_LENGTH, optOverlapLength);
362+
partationData.put(JSONKeys.MIN_OVERLAP_LENGTH, minOverlapLength);
363+
364+
JSONObject partationParameters = new JSONObject();
365+
partationParameters.put(JSONKeys.PARTITIONING_INFORMATION, partationData);
366+
367+
return partationData;
368+
}
369+
370+
213371
/**
214372
*
215373
* @param function

0 commit comments

Comments
 (0)