use of org.jbei.ice.lib.dto.entry.SequenceInfo in project ice by JBEI.
the class PartSequenceTest method testGet.
@Test
public void testGet() throws Exception {
Account account = AccountCreator.createTestAccount("PartSequenceTest.testGet", false);
Strain strain = TestEntryCreator.createTestStrain(account);
PartSequence partSequence = new PartSequence(account.getEmail(), strain.getRecordId());
FeaturedDNASequence sequence = partSequence.get();
Assert.assertNull(sequence);
ByteArrayInputStream inputStream = new ByteArrayInputStream(genbank.getBytes());
SequenceInfo sequenceInfo = partSequence.parseSequenceFile(inputStream, "testFile.gb");
Assert.assertNotNull(sequenceInfo);
FeaturedDNASequence featuredDNASequence = (FeaturedDNASequence) sequenceInfo.getSequence();
Assert.assertNotNull(featuredDNASequence);
Assert.assertEquals(1, featuredDNASequence.getFeatures().size());
sequence = partSequence.get();
Assert.assertNotNull(sequence);
Assert.assertEquals(234, sequence.getSequence().length());
Assert.assertEquals(1, sequence.getFeatures().size());
}
use of org.jbei.ice.lib.dto.entry.SequenceInfo in project ice by JBEI.
the class PartSequence method save.
protected SequenceInfo save(DNASequence dnaSequence, String sequenceString, String fileName) {
Sequence sequence = SequenceController.dnaSequenceToSequence(dnaSequence);
sequence.setSequenceUser(sequenceString);
sequence.setEntry(entry);
if (!StringUtils.isBlank(fileName))
sequence.setFileName(fileName);
Sequence result = sequenceDAO.saveSequence(sequence);
BlastPlus.scheduleBlastIndexRebuildTask(true);
SequenceInfo info = result.toDataTransferObject();
info.setSequence(dnaSequence);
return info;
}
use of org.jbei.ice.lib.dto.entry.SequenceInfo in project ice by JBEI.
the class FileResource method uploadSequence.
/**
* this creates an entry if an id is not specified in the form data
*/
@POST
@Path("sequence")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadSequence(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("entryRecordId") String recordId, @FormDataParam("entryType") String entryType, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
try {
final String fileName = contentDispositionHeader.getFileName();
String userId = getUserId();
PartSequence partSequence;
if (StringUtils.isEmpty(recordId)) {
if (entryType == null) {
entryType = "PART";
}
EntryType type = EntryType.nameToType(entryType);
partSequence = new PartSequence(userId, type);
} else {
partSequence = new PartSequence(userId, recordId);
}
SequenceInfo info = partSequence.parseSequenceFile(fileInputStream, fileName);
if (info == null)
throw new WebApplicationException(Response.serverError().build());
return Response.status(Response.Status.OK).entity(info).build();
} catch (Exception e) {
Logger.error(e);
ErrorResponse response = new ErrorResponse();
response.setMessage(e.getMessage());
throw new WebApplicationException(Response.serverError().entity(response).build());
}
}
use of org.jbei.ice.lib.dto.entry.SequenceInfo in project ice by JBEI.
the class BulkUploadResource method uploadSequenceFile.
@POST
@Path("/{id}/sequence")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response uploadSequenceFile(@PathParam("id") long uploadId, @FormDataParam("file") InputStream fileInputStream, @FormDataParam("entryId") long entryId, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
try {
String fileName = contentDispositionHeader.getFileName();
String userId = requireUserId();
String sequence = Utils.getString(fileInputStream);
SequenceInfo sequenceInfo = controller.addSequence(userId, uploadId, entryId, sequence, fileName);
if (sequenceInfo == null) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Response.Status.OK).entity(sequenceInfo).build();
} catch (IOException e) {
Logger.error(e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
Aggregations