Search in sources :

Example 1 with Sequences

use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.

the class SequenceResource method updateSequences.

@PUT
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response updateSequences(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDisposition) {
    String userId = requireUserId();
    try {
        Sequences controller = new Sequences(userId);
        List<String> errors = controller.bulkUpdate(userId, fileInputStream);
        return super.respond(errors);
    } catch (PermissionException e) {
        throw new WebApplicationException(e.getMessage(), Response.Status.UNAUTHORIZED);
    } catch (Exception e) {
        Logger.error(e);
        throw new WebApplicationException(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Sequences(org.jbei.ice.lib.entry.sequence.Sequences) PermissionException(org.jbei.ice.lib.access.PermissionException)

Example 2 with Sequences

use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.

the class FileResource method createSequenceModel.

/**
 * Create a model of the uploaded sequence file. Note that this does not associate the sequence
 * with any existing entry. It just parses the uploaded file
 */
@POST
@Path("sequence/model")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response createSequenceModel(@FormDataParam("file") InputStream fileInputStream, @FormDataParam("file") FormDataContentDisposition contentDispositionHeader) {
    final String fileName = contentDispositionHeader.getFileName();
    Sequences sequences = new Sequences(requireUserId());
    try {
        return super.respond(sequences.parseSequence(fileInputStream, fileName));
    } catch (InvalidFormatParserException e) {
        throw new WebApplicationException(e.getMessage());
    }
}
Also used : Sequences(org.jbei.ice.lib.entry.sequence.Sequences) TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) InvalidFormatParserException(org.jbei.ice.lib.parsers.InvalidFormatParserException)

Example 3 with Sequences

use of org.jbei.ice.lib.entry.sequence.Sequences in project ice by JBEI.

the class PartResource method getSequence.

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/sequence")
public Response getSequence(@PathParam("id") final String partId, @DefaultValue("false") @QueryParam("remote") boolean isRemote, @QueryParam("token") String remoteUserToken, @QueryParam("userId") String remoteUserId, @QueryParam("folderId") long fid, @DefaultValue("true") @QueryParam("annotations") boolean includeAnnotations) {
    final FeaturedDNASequence sequence;
    final String userId = getUserId();
    Sequences sequences = new Sequences(userId);
    if (isRemote) {
        // entry exists remotely
        sequence = remoteEntries.getSequence(userId, fid, partId);
    } else {
        // what request is being responded to (local or remote)
        if (StringUtils.isEmpty(userId)) {
            RegistryPartner partner = requireWebPartner();
            if (StringUtils.isEmpty(remoteUserToken) || fid == 0) {
                sequence = new PartSequence(userId, partId).get(includeAnnotations);
            } else {
                sequence = sequences.getRequestedSequence(partner, remoteUserId, remoteUserToken, partId, fid);
            }
        } else {
            // user id can be null if partId is public
            sequence = new PartSequence(userId, partId).get(includeAnnotations);
        }
    }
    return Response.status(Response.Status.OK).entity(sequence).build();
}
Also used : PartTraceSequences(org.jbei.ice.lib.entry.sequence.PartTraceSequences) Sequences(org.jbei.ice.lib.entry.sequence.Sequences) TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) RegistryPartner(org.jbei.ice.lib.dto.web.RegistryPartner) PartSequence(org.jbei.ice.lib.entry.sequence.PartSequence) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence)

Aggregations

Sequences (org.jbei.ice.lib.entry.sequence.Sequences)3 TraceSequences (org.jbei.ice.lib.entry.sequence.analysis.TraceSequences)2 PermissionException (org.jbei.ice.lib.access.PermissionException)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 RegistryPartner (org.jbei.ice.lib.dto.web.RegistryPartner)1 PartSequence (org.jbei.ice.lib.entry.sequence.PartSequence)1 PartTraceSequences (org.jbei.ice.lib.entry.sequence.PartTraceSequences)1 InvalidFormatParserException (org.jbei.ice.lib.parsers.InvalidFormatParserException)1