Search in sources :

Example 1 with Annotations

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

the class AnnotationResource method curate.

/**
     * Curate available annotations to include or exclude them from auto-annotation feature
     *
     * @param list list of annotations each with specified curate
     */
@PUT
@Produces(MediaType.APPLICATION_JSON)
public Response curate(List<DNAFeature> list) {
    String userId = requireUserId();
    Annotations annotations = new Annotations(userId);
    try {
        final Type fooType = new TypeToken<ArrayList<DNAFeature>>() {
        }.getType();
        final Gson gson = new GsonBuilder().create();
        final ArrayList<DNAFeature> features = gson.fromJson(gson.toJsonTree(list), fooType);
        annotations.curate(features);
        return super.respond(true);
    } catch (PermissionException e) {
        Logger.error(e);
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) MediaType(javax.ws.rs.core.MediaType) Type(java.lang.reflect.Type) Annotations(org.jbei.ice.lib.entry.sequence.annotation.Annotations) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) DNAFeature(org.jbei.ice.lib.dto.DNAFeature)

Example 2 with Annotations

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

the class AnnotationResource method getAnnotationsForSequence.

/**
     * Generates annotations for the passed sequence
     *
     * @param sequence sequence wrapper.
     * @return annotations for sequence
     */
@POST
public Response getAnnotationsForSequence(FeaturedDNASequence sequence) {
    String userId = getUserId();
    Annotations annotations = new Annotations(userId);
    FeaturedDNASequence annotatedSequence = annotations.generate(sequence);
    if (annotatedSequence == null)
        throw new WebApplicationException();
    return super.respond(annotatedSequence);
}
Also used : Annotations(org.jbei.ice.lib.entry.sequence.annotation.Annotations) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence)

Example 3 with Annotations

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

the class AnnotationResource method rebuildAnnotations.

@PUT
@Path("/indexes")
public Response rebuildAnnotations() {
    String userId = requireUserId();
    Annotations annotations = new Annotations(userId);
    try {
        annotations.rebuild();
    } catch (PermissionException pe) {
        Logger.error(pe);
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    }
    return super.respond(true);
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Annotations(org.jbei.ice.lib.entry.sequence.annotation.Annotations)

Example 4 with Annotations

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

the class PartResource method getAutoAnnotations.

@GET
@Path("/{id}/annotations/auto")
@Produces(MediaType.APPLICATION_JSON)
public Response getAutoAnnotations(@PathParam("id") long partId, @QueryParam("ownerFeatures") boolean ownerFeatures) {
    String userId = requireUserId();
    log(userId, "requesting auto annotations for entry " + partId);
    Annotations annotations = new Annotations(userId);
    return super.respond(annotations.generate(partId, ownerFeatures));
}
Also used : Annotations(org.jbei.ice.lib.entry.sequence.annotation.Annotations)

Example 5 with Annotations

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

the class AnnotationResource method getFeatures.

/**
     * Retrieve list of annotations available.
     * Administrative privileges required
     *
     * @param offset paging start
     * @param limit  maximum number of results to return
     * @param sort   sort field
     * @param asc    sort order
     */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getFeatures(@DefaultValue("0") @QueryParam("offset") final int offset, @DefaultValue("15") @QueryParam("limit") final int limit, @DefaultValue("created") @QueryParam("sort") final String sort, @DefaultValue("false") @QueryParam("asc") final boolean asc, @QueryParam("filter") String filter) {
    String userId = requireUserId();
    Annotations annotations = new Annotations(userId);
    try {
        if (filter != null && !filter.isEmpty())
            return super.respond(annotations.filter(offset, limit, filter));
        return super.respond(annotations.get(offset, limit, sort));
    } catch (PermissionException pe) {
        throw new WebApplicationException(Response.Status.FORBIDDEN);
    }
}
Also used : PermissionException(org.jbei.ice.lib.access.PermissionException) Annotations(org.jbei.ice.lib.entry.sequence.annotation.Annotations)

Aggregations

Annotations (org.jbei.ice.lib.entry.sequence.annotation.Annotations)5 PermissionException (org.jbei.ice.lib.access.PermissionException)3 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 MediaType (javax.ws.rs.core.MediaType)1 DNAFeature (org.jbei.ice.lib.dto.DNAFeature)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1