Skip to content

Commit b5685bd

Browse files
committed
added method to modify protien encoding sequence
1 parent 1649e86 commit b5685bd

5 files changed

Lines changed: 131 additions & 29 deletions

File tree

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

Lines changed: 44 additions & 27 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

@@ -383,33 +385,48 @@ public JSONObject getJobReport(final String jobUUID)
383385
// throw new BOOSTClientException(e.getLocalizedMessage());
384386
// }
385387
// }
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
388+
389+
390+
/**
391+
* The polish() method verifies the sequences in a given file against the
392+
* gene synthesis constraints of a commercial synthesis vendor.
393+
* In case of violations, the polish() method modifies the coding regions
394+
* of the sequence using the specified codon replacement strategy.
395+
*
396+
* @param sequencesFilename ... the name of the file that contains the sequences
397+
* @param type ... the type of the sequences, i.e. DNA, RNA, Protein
398+
* @param bCodingSequences ... if the sequences are encoded in a format that does not
399+
* support sequence feature annotations and if bCoding sequences is set to true,
400+
* then are all sequences are treated as coding sequences. If the sequences are
401+
* encoded in a format that does support sequence feature annotations, then the
402+
* bCodingSequences flag is ignored.
403+
* @param vendor ... the name of commercial synthesis provider
404+
* @param strategy ... the codon replacement strategy
405+
* @param codonUsageTableFilename ... the name of the file that contains the codon
406+
* usage table
407+
*
408+
* @throws BOOSTClientException
409+
* @throws BOOSTBackEndException
410+
*/
411+
public String polish(
412+
final String sequencesFilename,
413+
boolean bCodingSequences,
414+
Vendor vendor,
415+
Strategy strategy,
416+
final FileFormat outputFormat,
417+
final String codonUsageTable)
418+
throws BOOSTClientException, BOOSTBackEndException {
419+
420+
// construct the request's JSON object
421+
JSONObject requestData = RequestBuilder.buildPolish( sequencesFilename,
422+
bCodingSequences, vendor, strategy, outputFormat, codonUsageTable);
423+
424+
return submitJob(requestData);
425+
426+
}
427+
428+
429+
// check if the user did a login previously
413430
// if(null == token) {
414431
// throw new BOOSTClientException("You must authenticate first!");
415432
// }

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,74 @@ public static JSONObject buildVerify(
210210
return requestData;
211211
}
212212

213+
214+
/**
215+
*
216+
* @param sequencesFilename ... the name of the file that contains the sequences
217+
* @param type ... the type of the sequences, i.e. DNA, RNA, Protein
218+
* @param bCodingSequences ... if the sequences are encoded in a format that does not
219+
* support sequence feature annotations and if bCoding sequences is set to true,
220+
* then are all sequences are treated as coding sequences. If the sequences are
221+
* encoded in a format that does support sequence feature annotations, then the
222+
* bCodingSequences flag is ignored.
223+
* @param vendor ... the name of commercial synthesis provider
224+
* @param strategy ... the codon replacement strategy
225+
* @param codonUsageTableFilename ... the name of the file that contains the codon
226+
* usage table
227+
*
228+
* @throws BOOSTClientException
229+
*/
230+
public static JSONObject buildPolish(
231+
final String sequencesFilename,
232+
boolean bCodingSequences,
233+
Vendor vendor,
234+
Strategy strategy,
235+
final FileFormat outputFormat,
236+
final String codonUsageTable)
237+
throws BOOSTClientException {
238+
239+
//-------------------------------------
240+
// verify the given values
241+
ParameterValueVerifier.verifyFilename(BOOSTConstants.INPUT_FILENAME, sequencesFilename);
242+
ParameterValueVerifier.verifyNull(BOOSTConstants.VENDOR, vendor);
243+
try {
244+
ParameterValueVerifier.verifyFilename(BOOSTConstants.CODON_USAGE_TABLE, codonUsageTable);
245+
} catch(Exception e) {}
246+
ParameterValueVerifier.verifyNull(BOOSTConstants.OUTPUT_FORMAT, outputFormat);
247+
ParameterValueVerifier.verifyNull(BOOSTConstants.STRATEGY, strategy);
248+
//----------------------------------------
249+
250+
JSONObject modifiedData = new JSONObject();
251+
252+
//-----------------------------------------
253+
//JOB INFORMATION
254+
modifiedData.put(JSONKeys.JOB_INFORMATION,
255+
RequestBuilder.buildJobInformation(BOOSTFunctions.POLISH));
256+
//-----------------------------------------
257+
258+
// sequence information
259+
modifiedData.put(JSONKeys.SEQUENCE_INFORMATION,
260+
RequestBuilder.buildSequenceData(sequencesFilename, SequenceType.DNA, bCodingSequences ));
261+
//-----------------------------------------
262+
263+
// constraints
264+
modifiedData.put(JSONKeys.VENDOR_NAME, vendor);
265+
//------------------------------------------
266+
267+
// modification information
268+
modifiedData.put(JSONKeys.MODIFICATION_INFORMATION,
269+
RequestBuilder.buildModificationData(strategy, codonUsageTable));
270+
//-------------------------------------------
271+
272+
// output information
273+
modifiedData.put(JSONKeys.OUTPUT_INFORMATION,
274+
RequestBuilder.buildOutputData(outputFormat));
275+
//-------------------------------------------------
276+
277+
278+
return modifiedData;
279+
}
280+
213281
/**
214282
*
215283
* @param function

src/main/java/gov/doe/jgi/boost/client/constants/BOOSTConstants.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ public class BOOSTConstants {
99
public static final String CODON_USAGE_TABLE = "codon usage table";
1010
public static final String CODON_STRATEGY = "strategy";
1111
public static final String OUTPUT_FORMAT = "output format";
12-
12+
public static final String SEQUENCE_TYPE = "sequence_type";
13+
public static final String VENDOR = "vendor";
14+
public static final String STRATEGY = "strategy";
15+
1316
}

src/main/java/gov/doe/jgi/boost/client/constants/BOOSTFunctions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public enum BOOSTFunctions {
88

99
VERIFY,
1010

11-
MODIFY,
11+
POLISH,
1212

1313
PARTITION
1414
}

src/test/java/gov/doe/jgi/boost/client/DemoClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import gov.doe.jgi.boost.client.constants.BOOSTResources;
1010
import gov.doe.jgi.boost.enums.FileFormat;
1111
import gov.doe.jgi.boost.enums.Strategy;
12+
import gov.doe.jgi.boost.enums.Vendor;
1213

1314
/**
1415
* The DemoClient exemplifies how to invoke each functionality
@@ -72,6 +73,19 @@ public static void main(String[] args)
7273
jobUUIDs.add(dnaVarificationJobUUID);
7374
}
7475

76+
// polish the given DNA
77+
String polishDNAJobUUID = client.polish(
78+
"./data/dna.fasta", // input sequence
79+
true, // encoding sequences support sequence feature annotations
80+
Vendor.JGI, // vendor
81+
Strategy.Balanced2Random, // codon selection strategy
82+
FileFormat.SBOL, // output format
83+
"Saccharomyces cerevisiae"); // // predefined host
84+
if (null != polishDNAJobUUID) {
85+
jobUUIDs.add(polishDNAJobUUID);
86+
}
87+
88+
7589
// for all jobs, we check their status
7690
for(String jobUUID : jobUUIDs) {
7791

0 commit comments

Comments
 (0)