Search in sources :

Example 1 with TraceSequences

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

the class PartResource method deleteTrace.

@DELETE
@Path("/{id}/traces/{traceId}")
public Response deleteTrace(@Context final UriInfo info, @PathParam("id") final long partId, @PathParam("traceId") final long traceId) {
    final String userId = getUserId();
    TraceSequences traceSequences = new TraceSequences();
    if (!traceSequences.deleteTraceSequence(userId, partId, traceId)) {
        return super.respond(Response.Status.UNAUTHORIZED);
    }
    return super.respond(Response.Status.OK);
}
Also used : PartTraceSequences(org.jbei.ice.lib.entry.sequence.PartTraceSequences) TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences)

Example 2 with TraceSequences

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

the class PartSequence method update.

/**
 * Updates the sequence information associated with this part with the referenced one.
 * <br>
 * Write privileges on the entry are required
 *
 * @param updatedSequence new sequence to associate with this part
 */
public void update(FeaturedDNASequence updatedSequence, boolean parseSequence) {
    entryAuthorization.expectWrite(userId, entry);
    Sequence existing = sequenceDAO.getByEntry(this.entry);
    // update with raw sequence if no sequence object is passed
    if (parseSequence) {
        // sometimes the whole sequence is sent in the string portion (when there are no features)
        // no features to add
        updatedSequence = GeneralParser.parse(updatedSequence.getSequence());
    } else if (updatedSequence.getSequence().isEmpty() && StringUtils.isNotBlank(existing.getSequence())) {
        updatedSequence.setSequence(existing.getSequence());
    }
    // convert sequence wrapper to sequence storage model
    Sequence sequence = SequenceUtil.dnaSequenceToSequence(updatedSequence);
    if (sequence == null)
        return;
    // todo : commenting out for now
    if (existing != null) {
        SequenceVersionHistory history = new SequenceVersionHistory(userId, existing.getId());
        // get features for existing entry
        existing.setSequenceFeatures(new HashSet<>(sequenceFeatureDAO.getEntrySequenceFeatures(this.entry)));
        // 1. check sequence string to see if it has changed
        checkSequenceString(history, existing, sequence);
        // 2. check features
        checkForNewFeatures(existing, sequence);
        // 3. check for removed features
        checkRemovedFeatures(existing, sequence);
        // 4. check if any existing features are updated
        checkForUpdatedFeatures(existing, sequence);
        // rebuild the trace sequence alignments // todo : this might not be needed for all updates
        new TraceSequences().rebuildAllAlignments(entry);
        // rebuild blast
        scheduleBlastIndexRebuildTask(Action.UPDATE, this.entry.getPartNumber());
    } else {
        save(updatedSequence);
    }
}
Also used : TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) FeaturedDNASequence(org.jbei.ice.lib.dto.FeaturedDNASequence)

Example 3 with TraceSequences

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

the class FileResource method getTraceSequenceFile.

@GET
@Path("trace/{fileId}")
public Response getTraceSequenceFile(@PathParam("fileId") String fileId, @QueryParam("sid") String sid) {
    TraceSequences traceSequences = new TraceSequences();
    final TraceSequence traceSequence = traceSequences.getTraceSequenceByFileId(fileId);
    if (traceSequence != null) {
        final File file = traceSequences.getFile(traceSequence);
        return addHeaders(Response.ok(file), traceSequence.getFilename());
    }
    return Response.serverError().build();
}
Also used : TraceSequence(org.jbei.ice.storage.model.TraceSequence) TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) File(java.io.File)

Example 4 with TraceSequences

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

the class SequenceTraceResource 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();
    TraceSequences sequences = new TraceSequences();
    List<String> errors = sequences.bulkUpdate(userId, fileInputStream);
    return super.respond(errors);
}
Also used : TraceSequences(org.jbei.ice.lib.entry.sequence.analysis.TraceSequences) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

TraceSequences (org.jbei.ice.lib.entry.sequence.analysis.TraceSequences)4 File (java.io.File)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Produces (javax.ws.rs.Produces)1 FeaturedDNASequence (org.jbei.ice.lib.dto.FeaturedDNASequence)1 PartTraceSequences (org.jbei.ice.lib.entry.sequence.PartTraceSequences)1 TraceSequence (org.jbei.ice.storage.model.TraceSequence)1