Package it.unimi.dsi.fastutil.bytes

Examples of it.unimi.dsi.fastutil.bytes.ByteArrayList


    void runInput(InputStream in, AbstractDownload d) throws IOException {
        Logger.getLogger(Downloader.class.getName()).entering(Downloader.class.getName(), "runInput");
        if (d.getStatus() == DownloadStatus.DOWNLOADING) {
            int read;
            StopWatch bufferWatch = new StopWatch();
            ByteArrayList chunk = new ByteArrayList();
            byte inputBuffer[] = new byte[128];
            byte outputBuffer[] = new byte[128];
            int multiplier = 1;
            int growCount = 0;
            int shrinkCount = 0;
            int changeOn = 5;
            int accelerateOn = 10;
            bufferWatch.start();
            read = in.read(inputBuffer);
            d.initDownloadTime();
            while (read != -1 && d.getStatus() == DownloadStatus.DOWNLOADING) {
                assert (multiplier > 0);
                for (int i = 0; i < multiplier && read != -1 && d.getStatus() == DownloadStatus.DOWNLOADING; i++) {
                    chunk.addElements(chunk.size(), inputBuffer, 0, read);
                    read = in.read(inputBuffer);
                }
                d.updateDownloadTime();
                if (chunk.size() > outputBuffer.length) {
                    outputBuffer = new byte[chunk.size()];
                }
                processor.doChunck(chunk.size(), chunk.toByteArray(outputBuffer));
                d.setDownloaded(d.getDownloaded() + chunk.size());
                chunk.clear();
                bufferWatch.add();
                //System.out.print(bufferWatch);
                long maxTime = getdSettings().getBufferTime() * 1000000;
                if (bufferWatch.getTime() < maxTime) {
                    growCount++;
View Full Code Here


        ObjectArrayList<AlignmentBlock> blocks = new ObjectArrayList<AlignmentBlock>();
        ObjectArrayList<AlignmentBlock> insertionBlocks = new ObjectArrayList<AlignmentBlock>();

        int start = alignmentEntry.getPosition();
        ByteArrayList bases = new ByteArrayList();
        ByteArrayList scores = new ByteArrayList();
        int readLength = alignmentEntry.getQueryLength();

        byte[] readBases = new byte[readLength];
        byte[] readQual = new byte[readLength];
        Arrays.fill(readBases, (byte) '=');
        if (alignmentEntry.hasReadQualityScores()) {
            readQual = alignmentEntry.getReadQualityScores().toByteArray();
        } else {
            Arrays.fill(readQual, (byte) 40);
        }
        int j = 0;
        int insertedBases = 0;
        int deletedBases = 0;
        final int leftPadding = alignmentEntry.getQueryPosition();
        boolean showSoftClipped = PreferenceManager.getInstance().getAsBoolean(PreferenceManager.SAM_SHOW_SOFT_CLIPPED);
        if (showSoftClipped && entry.hasSoftClippedBasesLeft()) {
            int clipLength = entry.getSoftClippedBasesLeft().length();

            addSoftClipBlock(blocks, Math.max(0,
                    entry.getPosition() - clipLength),
                    entry.getSoftClippedBasesLeft(), readQual,
                    entry.hasSoftClippedQualityLeft(),
                    entry.getSoftClippedQualityLeft().toByteArray(),
                    0);
        }
        for (Alignments.SequenceVariation var : alignmentEntry.getSequenceVariationsList()) {
            final String from = var.getFrom();
            final int fromLength = from.length();
            final String to = var.getTo();
            final int toLength = from.length();
            final int sequenceVariationLength = Math.max(fromLength, toLength);
            final ByteString toQuality = var.getToQuality();

            if (hasReadInsertion(from)) {
                bases.clear();
                scores.clear();
                for (int i = 0; i < sequenceVariationLength; i++) {
                    final char toChar = i >= toLength ? '-' : to.charAt(i);
                    int size = toQuality.size();
                    final byte qual = size > 0 && i < size ? toQuality.byteAt(i) : 40;

                    bases.add((byte) toChar);
                    scores.add(qual);
                    deletedBases++;

                }
                addBlock(insertionBlocks, alignmentEntry.getPosition() + var.getPosition(), bases, scores);
                bases.clear();
                scores.clear();
            } else if (!to.contains("-")) {
                for (int i = 0; i < toLength; i++) {
                    final int offset = j + var.getPosition() + i - 1 + leftPadding - insertedBases;
                    if (offset > 0 && offset < readBases.length) {
                        readBases[offset] = (byte) to.charAt(i);
                        if (i < toQuality.size()) {
                            readQual[offset] = toQuality.byteAt(i);
                        }
                    }

                }
            } else {
                // has read deletion:
                insertedBases++;
            }
        }


        int pos = start;
        int matchLength = alignmentEntry.getQueryAlignedLength() - deletedBases;
        int endAlignmentRefPosition = matchLength + start;
        bases.clear();
        scores.clear();
        int maxIndex = Math.min(readBases.length, readQual.length);
        while (pos < endAlignmentRefPosition) {
            final int index = pos - start + leftPadding;
            if (index < maxIndex) {
                bases.add(readBases[index]);
                scores.add(readQual[index]);
            } else {
                break;
            }
            ++pos;
        }
View Full Code Here

                if (!block.isSoftClipped()) {

                    final int vrPos = var.getPosition() + entry.getPosition();
                    if (hasReadDeletion(var) && vrPos >= block.getStart() && vrPos <= block.getEnd()) {

                        ByteList leftBases = new ByteArrayList(block.getBases());
                        ByteList leftScores = new ByteArrayList(block.getQualities());
                        ByteList rightBases = new ByteArrayList(block.getBases());
                        ByteList rightScores = new ByteArrayList(block.getQualities());
                        int deletionPosition = var.getPosition() - 1;
                        leftBases = leftBases.subList(0, deletionPosition);
                        rightBases = rightBases.subList(deletionPosition, rightBases.size());

                        leftScores = leftScores.subList(0, deletionPosition);
                        rightScores = rightScores.subList(deletionPosition, rightScores.size());

                        AlignmentBlock left = AlignmentBlock.getInstance(getChr(), block.getStart(),
                                leftBases.toByteArray(new byte[leftBases.size()]),
                                leftScores.toByteArray(new byte[leftScores.size()]));

                        AlignmentBlock right = AlignmentBlock.getInstance(getChr(), block.getStart() + leftBases.size()
                                + var.getFrom().length(),
                                rightBases.toByteArray(new byte[rightBases.size()]),
                                rightScores.toByteArray(new byte[rightScores.size()]));

                        blocks.remove(block);
                        newBlocks.add(left);
                        newBlocks.add(right);
View Full Code Here

    /**
     * Constructor
     * @param capacity Capacity
     */
    public BasicByteArrayList(int capacity) {
      list = new ByteArrayList(capacity);
    }
View Full Code Here

TOP

Related Classes of it.unimi.dsi.fastutil.bytes.ByteArrayList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.