use of org.jbei.ice.lib.entry.sequence.PartSequence in project ice by JBEI.
the class AnnotationsTest method testCurate.
@Test
public void testCurate() throws Exception {
Account account = AccountCreator.createTestAccount("AnnotationsTest.testCurate", true);
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Assert.assertNotNull(plasmid);
SequenceDAO sequenceDAO = new SequenceDAO();
Assert.assertFalse(sequenceDAO.hasSequence(plasmid.getId()));
FeaturedDNASequence dnaSequence = GeneralParser.parse(sequenceString);
PartSequence partSequence = new PartSequence(account.getEmail(), plasmid.getRecordId());
partSequence.save(dnaSequence);
SequenceFeatureDAO sequenceFeatureDAO = new SequenceFeatureDAO();
List<SequenceFeature> sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
Assert.assertEquals(1, sequenceFeatures.size());
Feature feature = sequenceFeatures.get(0).getFeature();
DNAFeature dnaFeature = feature.toDataTransferObject();
Curation curation = new Curation();
curation.setExclude(true);
dnaFeature.setCuration(curation);
List<DNAFeature> features = new ArrayList<>();
features.add(dnaFeature);
Annotations annotations = new Annotations(account.getEmail());
annotations.curate(features);
sequenceFeatures = sequenceFeatureDAO.getEntrySequenceFeatures(plasmid);
feature = sequenceFeatures.get(0).getFeature();
Assert.assertTrue(feature.getCuration().isExclude());
}
use of org.jbei.ice.lib.entry.sequence.PartSequence in project ice by JBEI.
the class PartResource method deleteSequence.
@DELETE
@Path("/{id}/sequence")
public Response deleteSequence(@PathParam("id") final String partId) {
final String userId = requireUserId();
PartSequence partSequence = new PartSequence(userId, partId);
partSequence.delete();
return super.respond(true);
}
use of org.jbei.ice.lib.entry.sequence.PartSequence in project ice by JBEI.
the class FileResource method downloadSequence.
@GET
@Path("{partId}/sequence/{type}")
public Response downloadSequence(@PathParam("partId") final String partId, @PathParam("type") final String downloadType, @DefaultValue("-1") @QueryParam("remoteId") long remoteId, @QueryParam("sid") String sid) {
if (StringUtils.isEmpty(sessionId))
sessionId = sid;
final String userId = getUserId(sessionId);
if (remoteId != -1) {
RemoteSequence sequence = new RemoteSequence(remoteId, Long.decode(partId));
final InputStreamWrapper wrapper = sequence.get(downloadType);
StreamingOutput stream = output -> IOUtils.copy(wrapper.getInputStream(), output);
return addHeaders(Response.ok(stream), wrapper.getName());
} else {
InputStreamWrapper wrapper = new PartSequence(userId, partId).toFile(SequenceFormat.fromString(downloadType), true);
StreamingOutput stream = output -> IOUtils.copy(wrapper.getInputStream(), output);
return addHeaders(Response.ok(stream), wrapper.getName());
}
}
use of org.jbei.ice.lib.entry.sequence.PartSequence 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("extractHierarchy") @DefaultValue("false") boolean extractHierarchy, @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, extractHierarchy);
if (info == null)
throw new WebApplicationException(Response.serverError().build());
return Response.status(Response.Status.OK).entity(info).build();
} catch (IOException 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.entry.sequence.PartSequence in project ice by JBEI.
the class BulkUploads method addSequence.
public SequenceInfo addSequence(String userId, long bulkUploadId, long entryId, String sequenceString, String fileName) {
BulkUpload upload = dao.get(bulkUploadId);
if (upload == null)
return null;
authorization.expectWrite(userId, upload);
PartSequence partSequence = new PartSequence(userId, Long.toString(entryId));
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(sequenceString.getBytes(StandardCharsets.UTF_8));
return partSequence.parseSequenceFile(inputStream, fileName, false);
} catch (IOException e) {
Logger.error(e);
return null;
}
}
Aggregations