コード例 #1
0
ファイル: eutils.py プロジェクト: bopopescu/bioservices
    def ELink(self, db, dbfrom, Ids, cmd="neighbor"):
        """The Entrez links utility

        Responds to a list of UIDs in a given database with either a list of
        related UIDs (and relevancy scores) in the same database or a list of linked
        UIDs in another Entrez database; checks for the existence of a specified link
        from a list of one or more UIDs; creates a hyperlink to the primary LinkOut
        provider for a specific UID and database, or lists LinkOut URLs and attributes
        for multiple UIDs.

        :param str db: Database from which to retrieve UIDs. The value must be a valid Entrez database
            name. This is the destination database for the link operation.
        :param str dbfrom: Database containing the input UIDs. The value must be a
            valid Entrez database name (default = pubmed). This is the origin database of
            the link operation. If db and dbfrom are set to the same database value, then
            ELink will return computational neighbors within that database. Please see the
            full list of Entrez links for available computational neighbors. Computational
            neighbors have linknames that begin with dbname_dbname (examples:
            protein_protein, pcassay_pcassay_activityneighbor).
        :param str Ids: UID list. Either a single UID or a comma-delimited list of UIDs may be provided.
            All of the UIDs must be from the database specified by db. Limited  to 200 Ids
        :param str cmd: ELink command mode. The command mode specified which
            function ELink will perform. Some optional parameters only function for certain
            values of cmd (see http://www.ncbi.nlm.nih.gov/books/NBK25499/#chapter4.ELink).
            Examples are neighbor, prlinks.

        :: 

            >>> # Example: Find related articles to PMID 20210808
            >>> ret = s.ELink("pubmed", "pubmed", Ids="20210808", cmd="neighbor_score")


        """
        self._check_ids(Ids)
        self._check_db(db)
        self._check_db(dbfrom)
        assert cmd in ["neighbor", "neighbor_score", "neighbor_history",
"acheck", "llinks", "lcheck", "ncheck", "llinkslib" ,"prlinks"]

        s = RESTService("test","http://eutils.ncbi.nlm.nih.gov/entrez/eutils/")

        request = "elink.fcgi?db=%s&dbfrom=%s" % (db, dbfrom)
        request += "&id=%s" % Ids
        request += "&cmd=%s" % cmd
        ret = s.request(request)
        return ret
コード例 #2
0
ファイル: eutils.py プロジェクト: bopopescu/bioservices
 def _egquery_rest(self, term, retmode="xml"):
     self._check_retmode(retmode)
     s = RESTService("test","http://eutils.ncbi.nlm.nih.gov/entrez/eutils/")
     ret = s.request("egquery.fcgi?term=%s&retmode=%s" % (term, retmode))
     return ret
コード例 #3
0
ファイル: eutils.py プロジェクト: bopopescu/bioservices
 def _einfo_rest(self, db=None):
     s = RESTService("test","http://eutils.ncbi.nlm.nih.gov/entrez/eutils/")
     ret = s.request("einfo.fcgi?db=%s" % db)
     return ret
コード例 #4
0
ファイル: eutils.py プロジェクト: bopopescu/bioservices
 def _esummary_rest(self, db, Ids):
     # [(x.attrib['Name'], x.text) for x in ret.getchildren()[0].getchildren()[1:]]
     s = RESTService("test","http://eutils.ncbi.nlm.nih.gov/entrez/eutils/")
     ret = s.request("esummary.fcgi?db=%s&id=%s" % (db, Ids))
     return ret
コード例 #5
0
ファイル: eutils.py プロジェクト: bopopescu/bioservices
    def EFetch(self, db, Ids, retmode="xml", **kargs):
        """Access to the EFetch E-Utilities

        :param str db: Database from which to retrieve UIDs. The value must be a valid Entrez database
            name . This is the destination database for the link operation. 
        :param str Ids: UID list. Either a single UID or a comma-delimited list of UIDs may be provided.
            All of the UIDs must be from the database specified by db. Limited  to 200 Ids

        ::

            >>> ret = s.EFetch("omim", "269840")  --> ZAP70
            
            >>> ret = s.EFetch("taxonomy", "9606")
            >>> [x.text for x in ret.getchildren()[0].getchildren() if x.tag=="ScientificName"]
            ['H**o sapiens']

            >>> s = eutils.EUtils()
            >>> s.EFetch("sequences", "34577063", retmode="text", rettype="fasta")
            >gi|34577063|ref|NP_001117.2| adenylosuccinate synthetase isozyme 2 [H**o sapiens]
            MAFAETYPAASSLPNGDCGRPRARPGGNRVTVVLGAQWGDEGKGKVVDLLAQDADIVCRCQGGNNAGHTV
            VVDSVEYDFHLLPSGIINPNVTAFIGNGVVIHLPGLFEEAEKNVQKGKGLEGWEKRLIISDRAHIVFDFH
            QAADGIQEQQRQEQAGKNLGTTKKGIGPVYSSKAARSGLRMCDLVSDFDGFSERFKVLANQYKSIYPTLE
            IDIEGELQKLKGYMEKIKPMVRDGVYFLYEALHGPPKKILVEGANAALLDIDFGTYPFVTSSNCTVGGVC
            TGLGMPPQNVGEVYGVVKAYTTRVGIGAFPTEQDNEIGELLQTRGREFGVTTGRKRRCGWLDLVLLKYAH
            MINGFTALALTKLDILDMFTEIKVGVAYKLDGEIIPHIPANQEVLNKVEVQYKTLPGWNTDISNARAFKE
            LPVNAQNYVRFIEDELQIPVKWIGVGKSRESMIQLF

        The alias :meth:`taxonomy` uses the WSDL and provides an easier way to manipulate
        the ouptut.

        .. note:: uses the REST service only

        .. todo:: more documentation and optional arguments
        """
        #self._check_db(db)
        self._check_retmode(retmode)
        self._check_ids(Ids)
        s = RESTService("test","http://eutils.ncbi.nlm.nih.gov/entrez/eutils/")
        request = "efetch.fcgi?db=%s&id=%s&retmode=%s" % (db, Ids, retmode)

        if kargs.get("strand"):
            strand = kargs.get("strand")
            if strand in [1,2]:
                request += "&strand=%s" % strand
            else:
                raise ValueError("invalid strand. must be a number in 1,2")

        if kargs.get("complexity"):
            strand = kargs.get("complexity")
            if strand in [0,1,2,3,4]:
                request += "&complexity=%s" % strand
            else:
                raise ValueError("invalid complexity. must be a number in 0,1,2,3,4")

        if kargs.get("seq_start"):
            request += "&seq_start=%s" % kargs.get("seq_start")
        if kargs.get("seq_stop"):
            request += "&seq_stop=%s" % kargs.get("seq_stop")

        if kargs.get("rettype"):
            print kargs.get("rettype")
            request += "&rettype=%s" % kargs.get("rettype")

        ret = s.request(request)

        return ret