Take a list of pubmed IDs and add PMID prefix
        Args:
            :param pubmed_ids -  string representing publication
                                 ids seperated by a | symbol
        Returns:
            :return list: Pubmed curies
974138
def _process_pubmed_ids(pubmed_ids):
        
        if pubmed_ids.strip() == '':
            id_list = []
        else:
            id_list = pubmed_ids.split('|')
        for (i, val) in enumerate(id_list):
            id_list[i] = 'PMID:' + val
        return id_list
1174907
def __get_doi(pub):
        
        doi = ""
        # Doi location: d["pub"][idx]["identifier"][0]["id"]
        try:
            doi = pub["DOI"][0]["id"]
            doi = clean_doi(doi)
        except KeyError:
            logger_lpd_noaa.info("get_dois: KeyError: missing a doi key")
        except Exception:
            logger_lpd_noaa.info("get_dois: Exception: something went wrong")

        # if we received a doi that's a list, we want to concat into a single string
        if isinstance(doi, list):
            if len(doi) == 1:
                doi = doi[0]
            else:
                ", ".join(doi)
        return doi
599790
def missing_pdb_structures(self):
        """"""
        return [x.id for x in self.genes if not self.genes_with_experimental_structures.has_id(x.id)]
1160872
def create_unique_id(prefix, existing_ids):
    
    if prefix in existing_ids:
        suffix = 1
        while True:
            new_id = '{}_{}'.format(prefix, suffix)
            if new_id not in existing_ids:
                return new_id
            suffix += 1

    return prefix
458118
def _add_uid(self, uid, skip_handle=False):
        
        # We might add None values from wherever. Kill them here.
        uid = uid or ''
        if is_arxiv(uid):
            self._ensure_reference_field('arxiv_eprint', normalize_arxiv(uid))
        elif idutils.is_doi(uid):
            self._ensure_reference_field('dois', [])
            self.obj['reference']['dois'].append(idutils.normalize_doi(uid))
        elif idutils.is_handle(uid) and not skip_handle:
            self._ensure_reference_field('persistent_identifiers', [])
            self.obj['reference']['persistent_identifiers'].append({
                'schema': 'HDL',
                'value': idutils.normalize_handle(uid),
            })
        elif idutils.is_urn(uid):
            self._ensure_reference_field('persistent_identifiers', [])
            self.obj['reference']['persistent_identifiers'].append({
                'schema': 'URN',
                'value': uid,
            })
        elif self.RE_VALID_CNUM.match(uid):
            self._ensure_reference_field('publication_info', {})
            self.obj['reference']['publication_info']['cnum'] = uid
        elif is_cds_url(uid):
            self._ensure_reference_field('external_system_identifiers', [])
            self.obj['reference']['external_system_identifiers'].append({
                'schema': 'CDS',
                'value': extract_cds_id(uid),
            })
        elif is_ads_url(uid):
            self._ensure_reference_field('external_system_identifiers', [])
            self.obj['reference']['external_system_identifiers'].append({
                'schema': 'ADS',
                'value': extract_ads_id(uid),
            })
        else:
            # ``idutils.is_isbn`` is too strict in what it accepts.
            try:
                isbn = str(ISBN(uid))
                self._ensure_reference_field('isbn', {})
                self.obj['reference']['isbn'] = isbn
            except Exception:
                raise ValueError('Unrecognized uid type')
709999
def get_pmids(self, entry):
        
        pmids = []

        for citation in entry.iterfind("./reference/citation"):

            for pubmed_ref in citation.iterfind('dbReference[@type="PubMed"]'):

                pmid_number = pubmed_ref.get('id')

                if pmid_number in self.pmids:

                    pmid_sqlalchemy_obj = self.session.query(models.Pmid)\
                        .filter(models.Pmid.pmid == pmid_number).one()

                    pmids.append(pmid_sqlalchemy_obj)

                else:
                    pmid_dict = citation.attrib
                    if not re.search('^\d+$', pmid_dict['volume']):
                        pmid_dict['volume'] = -1

                    del pmid_dict['type'] # not needed because already filtered for PubMed

                    pmid_dict.update(pmid=pmid_number)
                    title_tag = citation.find('./title')

                    if title_tag is not None:
                        pmid_dict.update(title=title_tag.text)

                    pmid_sqlalchemy_obj = models.Pmid(**pmid_dict)
                    self.session.add(pmid_sqlalchemy_obj)
                    self.session.flush()

                    pmids.append(pmid_sqlalchemy_obj)

                    self.pmids |= set([pmid_number, ]) # extend the cache of identifiers

        return pmids
540039
def ip_info(self, ip, repository_ids=None):
        
        if not repository_ids:
            repository_ids = []
        repos = []
        for rid in repository_ids:
            repos.append({'id': rid})
        return self.raw_query('vuln', 'getIP', data={
            'ip': ip, 'repositories': repos})
545246
def get_provider_link_ids(self):
        
        id_list = []
        for id_ in self._my_map['providerLinkIds']:
            id_list.append(Id(id_))
        return IdList(id_list)
247360
def article_id_list(soup):
    """"""
    id_list = []
    for article_id_tag in raw_parser.article_id(soup):
        id_details = OrderedDict()
        set_if_value(id_details, "type", article_id_tag.get("pub-id-type"))
        set_if_value(id_details, "value", article_id_tag.text)
        set_if_value(id_details, "assigning-authority", article_id_tag.get("assigning-authority"))
        id_list.append(id_details)
    return id_list
1173816
def get_ids_with_prefix(portal_type, prefix):
    
    brains = search_by_prefix(portal_type, prefix)
    ids = map(api.get_id, brains)
    return ids
25336
def _tokens_to_subtoken_ids(self, tokens):
    
    ret = []
    for token in tokens:
      ret.extend(self._token_to_subtoken_ids(token))
    return ret
520255
def iterate_pubmed_identifiers(graph) -> Iterable[str]:
    
    return (
        data[CITATION][CITATION_REFERENCE].strip()
        for _, _, data in graph.edges(data=True)
        if has_pubmed(data)
    )
239994
def _add_span_node_ids_to_token_nodes(self):
        
        span_dict = defaultdict(list)
        for span_edge in self._spanning_relation_ids:
            token_node_id = self.edges[span_edge].target
            span_node_id = self.edges[span_edge].source
            span_dict[token_node_id].append(span_node_id)

        for token_node_id in span_dict:
            self.nodes[token_node_id].spans = span_dict[token_node_id]
15102
def ids(args):
    
    p = OptionParser(ids.__doc__)
    p.add_option("--prefix", type="int",
                 help="Find rep id for prefix of len [default: %default]")
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    clstrfile, = args
    cf = ClstrFile(clstrfile)
    prefix = opts.prefix
    if prefix:
        reads = list(cf.iter_reps_prefix(prefix=prefix))
    else:
        reads = list(cf.iter_reps())

    nreads = len(reads)
    idsfile = clstrfile.replace(".clstr", ".ids")
    fw = open(idsfile, "w")
    for i, name in reads:
        print("\t".join(str(x) for x in (i, name)), file=fw)

    logging.debug("A total of {0} unique reads written to `{1}`.".\
            format(nreads, idsfile))
    fw.close()

    return idsfile
709185
def _extract_pub(l, _root):
    
    logger_ts.info("enter _extract_pub")
    # For each publication entry
    for idx, pub in enumerate(l):
        logger_ts.info("processing publication #: {}".format(idx))
        # Get author data first, since that's the most ambiguously structured data.
        _root = _extract_authors(pub, idx, _root)
        # Go through data of this publication
        for k, v in pub.items():
            # Case 1: DOI ID. Don't need the rest of 'identifier' dict
            if k == 'identifier':
                try:
                    _root['pub' + str(idx + 1) + '_DOI'] = v[0]['id']
                except KeyError as e:
                    logger_ts.warn("_extract_pub: KeyError: no doi id: {}, {}".format(v, e))
            # Case 2: All other string entries
            else:
                if k != 'authors' and k != 'author':
                    _root['pub' + str(idx + 1) + '_' + k] = v
    return _root
710700
def read_pmid(pmid, source, cont_path, sparser_version, outbuf=None,
              cleanup=True):
    ""
    signal.signal(signal.SIGALRM, _timeout_handler)
    signal.alarm(60)
    try:
        if (source is 'content_not_found'
           or source.startswith('unhandled_content_type')
           or source.endswith('failure')):
            logger.info('No content read for %s.' % pmid)
            return  # No real content here.

        if cont_path.endswith('.nxml') and source.startswith('pmc'):
            new_fname = 'PMC%s%d.nxml' % (pmid, mp.current_process().pid)
            os.rename(cont_path, new_fname)

            try:
                sp = sparser.process_nxml_file(
                    new_fname,
                    outbuf=outbuf,
                    cleanup=cleanup
                    )
            finally:
                if cleanup and os.path.exists(new_fname):
                    os.remove(new_fname)
        elif cont_path.endswith('.txt'):
            content_str = ''
            with open(cont_path, 'r') as f:
                content_str = f.read()
            sp = sparser.process_text(
                content_str,
                outbuf=outbuf,
                cleanup=cleanup
                )
        signal.alarm(0)
    except Exception as e:
        logger.error('Failed to process data for %s.' % pmid)
        logger.exception(e)
        signal.alarm(0)
        return

    if sp is None:
        logger.error('Failed to run sparser on pmid: %s.' % pmid)
        return
    # At this point, we rewrite the PMID in the Evidence of Sparser
    # Statements according to the actual PMID that was read.
    sp.set_statements_pmid(pmid)
    s3_client.put_reader_output('sparser', sp.json_stmts, pmid,
                                sparser_version, source)
    return sp.statements
974143
def strids2ids(tokens: Iterable[str]) -> List[int]:
    
    return list(map(int, tokens))