Exemple #1
0
    def test_is_integer(self):
        # Valid result
        result = BARUtils.is_integer('5')
        self.assertTrue(result)

        # Valid but too large
        result = BARUtils.is_integer('99999999999999')
        self.assertFalse(result)

        # Invalid
        result = BARUtils.is_integer('abc')
        self.assertFalse(result)
Exemple #2
0
    def test_is_integer(self):
        # Valid result
        result = BARUtils.is_integer("5")
        self.assertTrue(result)

        # Valid but too large
        result = BARUtils.is_integer("99999999999999")
        self.assertFalse(result)

        # Invalid
        result = BARUtils.is_integer("abc")
        self.assertFalse(result)
Exemple #3
0
    def get(self, gene_id='', top_n=''):
        """This end point is a proxy for ATTED-II api version 4.
        This is used by ThaleMine.
        This end point is currently not cached.
        """
        gene_id = escape(gene_id)
        top_n = escape(top_n)

        # Is data valid
        if not BARUtils.is_arabidopsis_gene_valid(gene_id):
            return BARUtils.error_exit('Invalid gene id'), 400

        if not BARUtils.is_integer(top_n):
            return BARUtils.error_exit('Invalid count'), 400

        # Now query the web service
        payload = {'gene': gene_id, 'topN': top_n}
        resp = requests.get('https://atted.jp/cgi-bin/api4.cgi',
                            params=payload,
                            headers=request_headers)

        # I think the remote API always returns status 200, so skip status checking
        return resp.json()