private TIntv getIntv()

in server/catgenome/src/main/java/com/epam/catgenome/util/feature/reader/TabixReader.java [399:473]


    private TIntv getIntv(final String s) {
        TIntv intv = new TIntv();
        int col = 0;
        int beg = 0;
        int end = s.indexOf('\t', beg);
        while (end >= 0 || end == -1) {
            ++col;
            if (col == mSc) {
                intv.tid = chr2tid(end != -1 ? s.substring(beg, end) : s.substring(beg));
            } else if (col == mBc) {
                intv.end = Integer.parseInt(end != -1 ? s.substring(beg, end) : s.substring(beg));
                intv.beg = intv.end;
                if ((mPreset & CHAR_BIT_FLAG) != 0) {
                    ++intv.end;
                } else {
                    --intv.beg;
                }
                if (intv.beg < 0) {
                    intv.beg = 0;
                }
                if (intv.end < 1) {
                    intv.end = 1;
                }
            } else { // FIXME: SAM supports are not tested yet
                if ((mPreset & TYPE_FLAG) == 0) { // generic
                    if (col == mEc) {
                        intv.end = Integer.parseInt(end != -1 ? s.substring(beg, end) : s.substring(beg));
                    }
                } else if ((mPreset & TYPE_FLAG) == 1) { // SAM
                    if (col == 6) { // CIGAR
                        int l = 0, i, j;
                        String cigar = s.substring(beg, end);
                        for (i = 0, j = 0; i < cigar.length(); ++i) {
                            if (cigar.charAt(i) > '9') {
                                int op = cigar.charAt(i);
                                if (op == 'M' || op == 'D' || op == 'N') {
                                    l += Integer.parseInt(cigar.substring(j, i));
                                }
                                j = i + 1;
                            }
                        }
                        intv.end = intv.beg + l;
                    }
                } else if ((mPreset & TYPE_FLAG) == 2) { // VCF
                    String alt;
                    alt = end >= 0 ? s.substring(beg, end) : s.substring(beg);
                    if (col == 4) { // REF
                        if (!alt.isEmpty()) {
                            intv.end = intv.beg + alt.length();
                        }
                    } else if (col == 8) { // INFO
                        int eOff = -1, i = alt.indexOf("END=");
                        if (i == 0) {
                            eOff = 4;
                        } else if (i > 0) {
                            i = alt.indexOf(";END=");
                            if (i >= 0) {
                                eOff = i + 5;
                            }
                        }
                        if (eOff > 0) {
                            i = alt.indexOf(';', eOff);
                            intv.end = Integer.parseInt(i > eOff ? alt.substring(eOff, i) : alt.substring(eOff));
                        }
                    }
                }
            }
            if (end == -1) {
                break;
            }
            beg = end + 1;
            end = s.indexOf('\t', beg);
        }
        return intv;
    }