Search in sources :

Example 1 with SequenceAsString

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

the class RemoteTransfer method performTransfer.

/**
 * Transfers the sequence file for the part and any parts that are linked to it.
 * If the attached sequence was uploaded as a file or pasted, the system
 * transfers that. If not if attempts to convert the attached sequence to genbank format
 * and transfers that
 *
 * @param partner destination for the sequence transfer
 * @param data    data for part whose sequences are to be transferred
 */
protected void performTransfer(RemotePartner partner, PartData data) {
    String url = partner.getUrl();
    // check main entry for sequence
    if (sequenceDAO.hasSequence(data.getId())) {
        InputStreamWrapper wrapper = new SequenceAsString(SequenceFormat.GENBANK, data.getId(), true).get();
        if (wrapper != null && wrapper.getInputStream() != null) {
            try {
                String sequenceString = new String(wrapper.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
                remoteContact.transferSequence(url, data.getRecordId(), data.getType(), sequenceString);
            } catch (IOException e) {
                Logger.error("Cannot transfer sequence", e);
            }
        }
    }
    // check child entries
    if (data.getLinkedParts() == null)
        return;
    for (PartData linked : data.getLinkedParts()) {
        performTransfer(partner, linked);
    }
}
Also used : InputStreamWrapper(org.jbei.ice.lib.entry.sequence.InputStreamWrapper) PartData(org.jbei.ice.lib.dto.entry.PartData) SequenceAsString(org.jbei.ice.lib.entry.sequence.SequenceAsString) IOException(java.io.IOException) SequenceAsString(org.jbei.ice.lib.entry.sequence.SequenceAsString)

Aggregations

IOException (java.io.IOException)1 PartData (org.jbei.ice.lib.dto.entry.PartData)1 InputStreamWrapper (org.jbei.ice.lib.entry.sequence.InputStreamWrapper)1 SequenceAsString (org.jbei.ice.lib.entry.sequence.SequenceAsString)1