Convert DOI to WOS identifier.
346445
def doi_to_wos(wosclient, doi):
    """"""
    results = query(wosclient, 'DO="%s"' % doi, './REC/UID', count=1)
    return results[0].lstrip('WOS:') if results else None
932563
def Shape(docs, drop=0.0):
    """"""
    ids = numpy.zeros((sum(len(doc) for doc in docs),), dtype="i")
    i = 0
    for doc in docs:
        for token in doc:
            ids[i] = token.shape
            i += 1
    return ids, None
1298371
def pad(text, length):
    """"""
    text_length = wcswidth(text)

    if text_length < length:
        return text + ' ' * (length - text_length)

    return text
217235
def to_det_oid(self, det_id_or_det_oid):
        """"""
        try:
            int(det_id_or_det_oid)
        except ValueError:
            return det_id_or_det_oid
        else:
            return self.get_det_oid(det_id_or_det_oid)
84275
def to_subject_id(s):
    '''
    
    '''
    if not pimms.is_number(s) and not pimms.is_str(s):
        raise ValueError('invalid type for subject id: %s' % str(type(s)))
    if pimms.is_str(s):
        try: s = os.path.expanduser(s)
        except Exception: pass
        if os.path.isdir(s): s = s.split(os.sep)[-1]
    s = int(s)
    if s > 999999 or s < 100000:
        raise ValueError('subject ids must be 6-digit integers whose first digit is > 0')
    return s
634265
def get_string_index_oid(self, s):
        """"""
        return (len(self.get_bytes(s)), ) + self.get_bytes(s)
465395
def convertdistmethod(method_str):
        """"""
        if StringClass.string_match(method_str, 'Horizontal'):
            return 'h'
        elif StringClass.string_match(method_str, 'Vertical'):
            return 'v'
        elif StringClass.string_match(method_str, 'Pythagoras'):
            return 'p'
        elif StringClass.string_match(method_str, 'Surface'):
            return 's'
        elif method_str.lower() in ['h', 'v', 'p', 's']:
            return method_str.lower()
        else:
            return 's'
982900
def t_identifier(self, s):
        '
        self.rv.append(Token(type='IDENTIFIER', attr=s))
739144
def iddversiontuple(afile):
    """"""
    def versiontuple(vers):
        """version tuple"""
        return tuple([int(num) for num in vers.split(".")])
    try:
        fhandle = open(afile, 'rb')
    except TypeError:
        fhandle = afile
    line1 = fhandle.readline()
    try:
        line1 = line1.decode('ISO-8859-2')
    except AttributeError:
        pass
    line = line1.strip()
    if line1 == '':
        return (0,)
    vers = line.split()[-1]
    return versiontuple(vers)
701442
def identifiers(dataset_uri):
    """"""
    dataset = dtoolcore.DataSet.from_uri(dataset_uri)
    for i in dataset.identifiers:
        click.secho(i)
392876
def get_woeid(lat, lon):
    """"""
    yql = _YQL_WOEID.format(lat, lon)

    # send request
    tmpData = _yql_query(yql)

    if tmpData is None:
        _LOGGER.error("No woid is received!")
        return None

    # found woid?
    return tmpData.get("place", {}).get("woeid", None)
286729
def _pid_to_id(self, pid):
        """"""
        return d1_common.url.joinPathElements(
            self._base_url,
            self._version_tag,
            "resolve",
            d1_common.url.encodePathElement(pid),
        )
1083376
def wcs_to_coords(w, shape):
    """"""
    if w.naxis == 2:
        y, x = wcs_to_axes(w, shape)
    elif w.naxis == 3:
        z, y, x = wcs_to_axes(w, shape)
    else:
        raise Exception("Wrong number of WCS axes %i" % w.naxis)

    x = 0.5 * (x[1:] + x[:-1])
    y = 0.5 * (y[1:] + y[:-1])

    if w.naxis == 2:
        x = np.ravel(np.ones(shape) * x[:, np.newaxis])
        y = np.ravel(np.ones(shape) * y[np.newaxis, :])
        return np.vstack((x, y))

    z = 0.5 * (z[1:] + z[:-1])
    x = np.ravel(np.ones(shape) * x[:, np.newaxis, np.newaxis])
    y = np.ravel(np.ones(shape) * y[np.newaxis, :, np.newaxis])
    z = np.ravel(np.ones(shape) * z[np.newaxis, np.newaxis, :])

    return np.vstack((x, y, z))
666349
def filename_to_task_id(fname):
  """"""
  # This matches the order and size in WikisumBase.out_filepaths
  fname = os.path.basename(fname)
  shard_id_increment = {
      "train": 0,
      "dev": 800,
      "test": 900,
  }
  parts = fname.split("-")
  split = parts[1]
  shard_id = parts[2]
  task_id = int(shard_id) + shard_id_increment[split]
  return task_id
985082
def AUID(val):
    """"""
    retDict = {}
    for v in val:
        split = v.split(' : ')
        retDict[split[0]] = ' : '.join(split[1:])
    return retDict
265666
def id_fix(value):
    
    if value.startswith('KSC_M'):
        pass
    else:
        value = value.replace(':','_')
        if value.startswith('ERO') or value.startswith('OBI') or value.startswith('GO') or value.startswith('UBERON') or value.startswith('IAO'):
            value = 'obo:' + value
        elif value.startswith('birnlex') or value.startswith('nlx'):
            value = 'NIFSTD:' + value
        elif value.startswith('MESH'):
            value = ':'.join(value.split('_'))
        else:
            value = ':' + value

    return OntId(value).URIRef
1278648
def entry_id_from_cobra_encoding(cobra_id):
    """"""
    for escape, symbol in iteritems(_COBRA_DECODE_ESCAPES):
        cobra_id = cobra_id.replace(escape, symbol)
    return cobra_id