extract the umi and cell barcode from the read id (input as a
    string) using the specified separator
340068
def get_cell_umi_read_string(read_id, sep="_"):
    '''  '''

    try:
        return (read_id.split(sep)[-1].encode('utf-8'),
                read_id.split(sep)[-2].encode('utf-8'))
    except IndexError:
        raise ValueError(
            "Could not extract UMI or CB from the read ID, please"
            "check UMI and CB are encoded in the read name:"
            "%s" % read_id)
214954
private static int scanUriEscape(ByteToChar converter,
                                   byte []rawUri, int i, int len)
    throws IOException
  {
    int ch1 = i < len ? (rawUri[i++] & 0xff) : -1;

    if (ch1 == 'u') {
      ch1 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch2 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch3 = i < len ? (rawUri[i++] & 0xff) : -1;
      int ch4 = i < len ? (rawUri[i++] & 0xff) : -1;

      converter.addChar((char) ((toHex(ch1) << 12) +
                                (toHex(ch2) << 8) + 
                                (toHex(ch3) << 4) + 
                                (toHex(ch4))));
    }
    else {
      int ch2 = i < len ? (rawUri[i++] & 0xff) : -1;

      int b = (toHex(ch1) << 4) + toHex(ch2);;

      converter.addByte(b);
    }

    return i;
  }
660969
static ByteBuffer unescapeBytes(final CharSequence input)
    {
        int pos = 0, len = input.length();
        final byte[] result = new byte[len];
        ByteBuffer buffer = ByteBuffer.wrap(result);
        for (int i = 0; i < len; i++)
        {
            char c = input.charAt(i);
            if (c == '\\')
            {
                if (i + 1 < len)
                {
                    ++i;
                    c = input.charAt(i);
                    if (isOctal(c))
                    {
                        // Octal escape.
                        int code = digitValue(c);
                        if (i + 1 < len && isOctal(input.charAt(i + 1)))
                        {
                            ++i;
                            code = code * 8 + digitValue(input.charAt(i));
                        }
                        if (i + 1 < len && isOctal(input.charAt(i + 1)))
                        {
                            ++i;
                            code = code * 8 + digitValue(input.charAt(i));
                        }
                        result[pos++] = (byte) code;
                    }
                    else
                    {
                        switch (c)
                        {
                            case 'a':
                                result[pos++] = 0x07;
                                break;
                            case 'b':
                                result[pos++] = '\b';
                                break;
                            case 'f':
                                result[pos++] = '\f';
                                break;
                            case 'n':
                                result[pos++] = '\n';
                                break;
                            case 'r':
                                result[pos++] = '\r';
                                break;
                            case 't':
                                result[pos++] = '\t';
                                break;
                            case 'v':
                                result[pos++] = 0x0b;
                                break;
                            case '\\':
                                result[pos++] = '\\';
                                break;
                            case '\'':
                                result[pos++] = '\'';
                                break;
                            case '"':
                                result[pos++] = '\"';
                                break;

                            case 'x':
                                // hex escape
                                int code = 0;
                                if (i + 1 < len && isHex(input.charAt(i + 1)))
                                {
                                    ++i;
                                    code = digitValue(input.charAt(i));
                                }
                                else
                                {
                                    throw new InvalidEscapeSequenceException(
                                            "Invalid escape sequence: '\\x' with no digits");
                                }
                                if (i + 1 < len && isHex(input.charAt(i + 1)))
                                {
                                    ++i;
                                    code = code * 16 + digitValue(input.charAt(i));
                                }
                                result[pos++] = (byte) code;
                                break;

                            default:
                                throw new InvalidEscapeSequenceException(
                                        "Invalid escape sequence: '\\" + c + '\'');
                        }
                    }
                }
                else
                {
                    throw new InvalidEscapeSequenceException(
                            "Invalid escape sequence: '\\' at end of string.");
                }
            }
            else
            {
                result[pos++] = (byte) c;
            }
        }
        buffer.limit(pos);
        return buffer;
    }
1280169
private void scanIdent() {
        boolean isJavaIdentifierPart;
        char high;
        reader.putChar(true);
        do {
            switch (reader.ch) {
            case 'A': case 'B': case 'C': case 'D': case 'E':
            case 'F': case 'G': case 'H': case 'I': case 'J':
            case 'K': case 'L': case 'M': case 'N': case 'O':
            case 'P': case 'Q': case 'R': case 'S': case 'T':
            case 'U': case 'V': case 'W': case 'X': case 'Y':
            case 'Z':
            case 'a': case 'b': case 'c': case 'd': case 'e':
            case 'f': case 'g': case 'h': case 'i': case 'j':
            case 'k': case 'l': case 'm': case 'n': case 'o':
            case 'p': case 'q': case 'r': case 's': case 't':
            case 'u': case 'v': case 'w': case 'x': case 'y':
            case 'z':
            case '$': case '_':
            case '0': case '1': case '2': case '3': case '4':
            case '5': case '6': case '7': case '8': case '9':
                break;
            case '\u0000': case '\u0001': case '\u0002': case '\u0003':
            case '\u0004': case '\u0005': case '\u0006': case '\u0007':
            case '\u0008': case '\u000E': case '\u000F': case '\u0010':
            case '\u0011': case '\u0012': case '\u0013': case '\u0014':
            case '\u0015': case '\u0016': case '\u0017':
            case '\u0018': case '\u0019': case '\u001B':
            case '\u007F':
                reader.scanChar();
                continue;
            case '\u001A': // EOI is also a legal identifier part
                if (reader.bp >= reader.buflen) {
                    name = reader.name();
                    tk = tokens.lookupKind(name);
                    return;
                }
                reader.scanChar();
                continue;
            default:
                if (reader.ch < '\u0080') {
                    // all ASCII range chars already handled, above
                    isJavaIdentifierPart = false;
                } else {
                    if (Character.isIdentifierIgnorable(reader.ch)) {
                        reader.scanChar();
                        continue;
                    } else {
                        int codePoint = reader.peekSurrogates();
                        if (codePoint >= 0) {
                            if (isJavaIdentifierPart = Character.isJavaIdentifierPart(codePoint)) {
                                reader.putChar(true);
                            }
                        } else {
                            isJavaIdentifierPart = Character.isJavaIdentifierPart(reader.ch);
                        }
                    }
                }
                if (!isJavaIdentifierPart) {
                    name = reader.name();
                    tk = tokens.lookupKind(name);
                    return;
                }
            }
            reader.putChar(true);
        } while (true);
    }
439902
private String readAsciiUntilCrlf(InputStream in) throws IOException {
        StringBuilder builder = new StringBuilder();
        while (true) {
            int c = in.read();
            if (c == '\n' && builder.length() > 0 && builder.charAt(builder.length() - 1) == '\r') {
                builder.deleteCharAt(builder.length() - 1);
                return builder.toString();
            } else if (c == -1) {
                return builder.toString();
            } else {
                builder.append((char) c);
            }
        }
    }
889674
def parse_id(input_id):
    """"""
    parts = input_id.split(':')
    if len(parts) != 2:
        raise exceptions.CLIAbort(
            'Invalid ID %s: ID should be of the form "kind:id"' % input_id)
    return parts[0], int(parts[1])
860685
function extractSrt (buffer) {
  const zip = new AdmZip(buffer)
  const srtZipEntry = zip
    .getEntries()
    .find(zipEntry =>
      zipEntry.entryName.endsWith('.srt')
    )
  return zip.readAsText(srtZipEntry)
}
947064
private static Object readParam(DataInput reader) throws IOException {
		int type = reader.readUnsignedByte();
		switch (type) {
		case BYTE_ID:
			return Byte.valueOf(reader.readByte());
		case SHORT_ID:
			return Short.valueOf(reader.readShort());
		case INTEGER_ID:
			return Integer.valueOf(reader.readInt());
		case CHAR_ID:
			return Character.valueOf(reader.readChar());
		case LONG_ID:
			return Long.valueOf(reader.readLong());
		case FLOAT_ID:
			return Float.valueOf(reader.readFloat());
		case DOUBLE_ID:
			return Double.valueOf(reader.readDouble());
		case DATE_ID:
			return new Date(reader.readLong());
		case STRING_ID:
			return readString(reader);
		case NULL_ID:
			return null;
		}
		throw new DeserializerException("Wrong type of a parameter", "one of the B,S,I,C,L,F,D,T,O,N", Character.toString((char)type));
	}
400845
public final static int readMdLinkId(final StringBuilder out, final String in, final int start)
    {
        int pos = start;
        int counter = 1;
        while (pos < in.length())
        {
            final char ch = in.charAt(pos);
            boolean endReached = false;
            switch (ch)
            {
            case '\n':
                out.append(' ');
                break;
            case '[':
                counter++;
                out.append(ch);
                break;
            case ']':
                counter--;
                if (counter == 0)
                {
                    endReached = true;
                }
                else
                {
                    out.append(ch);
                }
                break;
            default:
                out.append(ch);
                break;
            }
            if (endReached)
            {
                break;
            }
            pos++;
        }

        return (pos == in.length()) ? -1 : pos;
    }
1339300
def parse_dmidecode(dmidecode_content, pythonic_keys=False):
    
    if len(dmidecode_content) < 3:
        return {}

    section = None
    obj = {}
    current = {}

    buf = "\n".join(dmidecode_content).strip()

    # Some versions of DMIDecode have an extra
    # level of indentation, as well as slightly
    # different configuration for each section.
    if "\tDMI type" in buf:
        pat = re.compile("^\t", flags=re.MULTILINE)
        buf = pat.sub("", buf)

        buf = buf.replace("\nDMI type", "DMI type")
        buf = buf.replace("\nHandle", "\n\nHandle")

    buf = buf.replace("\n\t\t", "\t")

    def fix_key(k):
        return k.lower().replace(" ", "_") if pythonic_keys else k

    for line in buf.splitlines():
        nbline = line.strip()
        if section:
            if not nbline:
                # There maybe some sections with the same name, such as:
                # processor_information
                if section in obj:
                    obj[section].append(current)
                else:
                    obj[section] = [current]
                current = {}
                section = key = None
                continue

            elif line.startswith("\t"):
                if ":" in line:
                    key, value = nbline.split(":", 1)
                    key = fix_key(key)
                    value = value.strip()

                if "\t" in value:
                    current[key] = list(filter(None, value.split("\t")))
                else:
                    current[key] = value
            else:
                section = None

        if not section:
            # Ignore 'Table at 0xBFFCB000' and similar.
            if not ('Table' in nbline or 'table' in nbline):
                section = fix_key(nbline)

    if section in obj:
        obj[section].append(current)
    else:
        obj[section] = [current]

    return obj
355555
private String parseJavaId() {
		StringBuilder sb = new StringBuilder();
		int ch;
		while (true) {
			ch = peekChar();
			if (ch == EOS || !isJavaIdentifierPart(ch)) {
				return sb.toString();
			}
			sb.append((char) ch);
			nextChar();
		}
	}
674848
public String extractToString(final String separator, final String endSeparator) throws DevFailed {
        logger.debug(LOG_EXTRACTING, this);
        return attributeImpl.extractToString(separator, endSeparator);
    }
341127
def get_barcode_umis(read, cell_barcode=False):
    ''' '''

    umi, cell = None, None
    try:
        read_name_elements = read.qname.split(":")
        for element in read_name_elements:
            if element.startswith("UMI_"):
                umi = element[4:].encode('utf-8')
            elif element.startswith("CELL_") and cell_barcode:
                cell = element[5:].encode('utf-8')

        if umi is None:
            raise ValueError()

        return umi, cell

    except:
        raise ValueError("Could not extract UMI +/- cell barcode from the "
                         "read tag")
896461
def p_expr_id_substr(p):
    
    entry = SYMBOL_TABLE.access_var(p[1], p.lineno(1), default_type=TYPE.string)
    p[0] = None
    if entry is None:
        return

    entry.accessed = True
    p[0] = make_strslice(p.lineno(1), entry, p[2][0], p[2][1])
609733
function getIdStringFromIdParts(source, idParts) {
        if (idParts.length === 1) {
            return null;
        }
        var i, l, idPart, idPartType, check = 0, nextIdNameCode;
        for (i = 0, l = idParts.length; i < l; i++) {
            if (idParts[i].type) {
                check = 1;
                break;
            }
        }
        if (check) {
            var ret = [];
            for (i = 0, l = idParts.length; i < l; i++) {
                idPart = idParts[i];
                idPartType = idPart.type;
                if (idPartType) {
                    nextIdNameCode = xtplAstToJs[idPartType](idPart);
                    pushToArray(source, nextIdNameCode.source);
                    ret.push(nextIdNameCode.exp);
                } else {
                    // literal a.x
                    ret.push(wrapByDoubleQuote(idPart));
                }
            }
            return ret;
        } else {
            return null;
        }
    }
634265
def get_string_index_oid(self, s):
        """"""
        return (len(self.get_bytes(s)), ) + self.get_bytes(s)
1334074
def _read_id_numbers(self):
        """"""
        _byte = self._read_fileng(4)
        _addr = '.'.join([str(_) for _ in _byte])
        return _addr