Giter Club home page Giter Club logo

bioscraping's Introduction

#Bioscraping

Web scrapers to interact with remote databases programatically in Python that makes a local cache of web data with sqlite3 to prevent excessive web traffic.

So far, implemented:

  • Uniprot by uniprot protein ID. (e.g. 'Q8BP71')
  • PubMed by PMID (e.g. '24213538')

#Install

##Python 2.7.x and 3.x pip install bioscraping

#Test

Real unit tests are absent, but you can test basic functionality with python test/not_a_real_test.py.

#Usage

##PubMed from bioscraping import PubMedClient

pubmed = PubMedClient()

defaults to writing a file called .bioscraping.pubmed.sqlite.db. Use PubMedClient(":memory:") for in-memory data storage.

pubmed.fetch(<PMID>)

Returns text with author and abstract for PMID.

##Uniprot

from bioscraping import UniprotClient

uniprot = UniprotClient()

defaults to writing a file called .bioscraping.uniprot.sqlite.db. Use UniprotClient(":memory:") for in-memory data storage.

uniprot.fetch(<Uniprot ID>)

Returns a dictionary of data parsed from xml.

#Buyer beware

UniprotClient has a potential race condition and tempfile needs to be implemented before it is safe for concurrent processes. (see TODO)

bioscraping's People

Contributors

mlovci avatar

Stargazers

Kobi Felton avatar Jeroen Van Goey avatar

Watchers

James Cloos avatar

bioscraping's Issues

Python 3 : TypeError urllib.requests

In python 3 using PubMedClient a type error is obtained.

    >> from bioscraping import PubMedClient
    >> pubmed = PubMedClient(':memory:')
    >> my_pmid = pubmed.fetch('1851123')

    TypeError: POST data should be bytes or an iterable of bytes. It cannot be of type str.

I have fixed this error like this:

at /bioscraping/pubmed.py in _download(pmid):

24: response = urllib.request.urlopen(request, data=data.encode("utf-8"))

Seems to work in python3 and 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.