Git Product home page Git Product logo

gisaid-scrapper's Introduction

GISAID scrapper

Scrapping tool for GISAID data regarding SARS-CoV-2. You need an active account in order to use it.

Preparations

Install all requirements for the scrapper.

pip install -r requirements.txt

You need to download a Firefox WebDriver for your operating system and place it in script's directory.

Your login and password can be provided in credentials.txt file in format:

login
password

Usage

usage: scrap.py [-h] [--username USERNAME] [--password PASSWORD]  
                          [--filename FILENAME] [--destination DESTINATION] 
                          [--headless [HEADLESS]] [--whole [WHOLE]]

optional arguments:
  -h, --help            show this help message and exit
  --username USERNAME, -u USERNAME
                        Username for GISAID
  --password PASSWORD, -p PASSWORD
                        Password for GISAID
  --filename FILENAME, -f FILENAME
                        Path to file with credentials (alternative, default:
                        credentials.txt)
  --destination DESTINATION, -d DESTINATION
                        Destination directory (default: fastas/)
  --headless [HEADLESS], -q [HEADLESS]
                        Headless mode (no browser window)
  --whole [WHOLE], -w [WHOLE]
                        Scrap whole genomes only

Example:

python3 scrap.py -u user -p pass -w

run the scrapper with username user and password pass, downloading only whole sequence data.

python3 scrap.py -w -q -d whole_genome

run the scrapper in headless mode with username and password read from credentials.txt, downloading only whole sequence data into whole_genome directory.

Result

The whole and partial genom sequences from GISAID will be downloaded into fastas/ directory. metadata.tsv file will also be created, containing following information for every sample:

  • Accession
  • Collection date
  • Location
  • Host
  • Additional location information
  • Gender
  • Patient age
  • Patient status
  • Specimen source
  • Additional host information
  • Outbreak
  • Last vaccinated
  • Treatment
  • Sequencing technology
  • Assembly method
  • Coverage
  • Comment
  • Length

as long as they were provided. You can interrupt the download and resume it later, the samples won't be downloaded twice. The tool has only been tested on windows 10.

Docker Image

It is also possible to run this scrapper in headless mode inside docker container. This allows to use it on any Operating System that is able to run Docker. Image created by Pawel Kulig and hosted on his DockerHub.

In this version, all parameters are provided via .env file -- login, password, destination, and whole genome flag.

Aside from gisaid_scrapper container Selenium contianer is used to operate in client server paradigm.

To run scrapper in container run:

docker-compose up

To run it detached add "-d" option.

To build Docker Image on your own run below command inside gisaid_scrapper directory:

docker build --tag name:tag .

geckodriver file inside gisaid_scrapper directory is required to perform this operation. See: https://github.com/mozilla/geckodriver/releases

gisaid-scrapper's People

Contributors

majkiw avatar pawelkulig1 avatar wwydmanski avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gisaid-scrapper's Issues

CAPTCHA Issue

They made CAPTCHA in order to prevent users from Crawling information

FYI

Thanks

driver.execute_script doesn't work

I can run the code and it will open up GISAID and put in my login details. However, it cannot hit the login button or proceed any further.

Error message: selenium.common.exceptions.ElementClickInterceptedException: Message: Element <td class="yui-dt0-col-d yui-dt-col-d yui-dt-sortable yui-dt-resizeable"> is not clickable at point (x,y) because another element <div class="yui-dt-bd"> obscures it

Hi, I keep getting this error message when trying to download the fasta files with both your original script and this updated one. I see in the updated script that it includes a scrolling function, but I'm still running into issues with the program not being able to continue because it following file isn't visible. Can you assist? Thank you!

Program break and check the "high coverage only"

Thanks for your great program. It makes me relaxed.

Program sometimes breaks when click "next". I guess the page is not loaded yet. So I add "time.sleep(2)" in "def go_to_next_page" to solve this problem.

Suggest: add a option to check "high coverage only" and select host "human". That will be helpful for us. Thanks.

Sequence remove

GISAID usually remove some sequences, so some new upload sequence couldn't be download. Do you have any method to solve it? may confirm all downloaded sequences the time...

TimeoutException

I changed time timeout to 900 but it still doesn't work

python3 gisaid-scrapper/scrap.py --filename credentials.txt --destination gisaid
Traceback (most recent call last):
File "gisaid-scrapper/scrap.py", line 55, in
scrapper.login(login, passwd)
File "/space/s2/lenore/virus_evolution/gisaid-scrapper/gisaid_scrapper.py", line 83, in login
WebDriverWait(self.driver, 900).until(cond.staleness_of(login_box))
File "/home/lenore/bin/anaconda2/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

Issue that the "Download button couldn't be found!"

Dear there,

I have a problem when running the script. I run the script: "python3 scrap.py -u ààà -p àààà -w", and got the error message about 30min later.

Traceback (most recent call last):
File "scrap.py", line 79, in
scrapper.download_packages('metadata_tsv')
File "/Users/qianqian/gisaid-scrapper/gisaid_scrapper.py", line 278, in download_packages
assert download is not None, "Download button couldn't be found!"
AssertionError: Download button couldn't be found!

Could you help to give some solution?

Thanks
Qianqian

time.sleep() too small

Couldn't download all genomes for two days (downloaded only 70%) because of errors. Every time script downloads some portion of genomes and raises an error. After increasing all time.sleep(x) to time.sleep(10) everywhere in the script i could finally download all genomes.

AMD Ryzen 3600x, 32 GB RAM, Ubuntu 18.04

Request to remove repository

Hello,

I'm relaying a request from GISAID to remove this repository. The use of these scrapers are negatively impacting the ability for GISAID to host this critical scientific data.

Thank you.

Add bulk download option

Would it be possible to add an option to download the bulk file, as when clicking "Download" on the bottom right of the browser, as well as the Acknowledgement Table?

Otherwise: Thanks for this truly useful package!

Element is stale

Hello,

thank you for making your scraper public.
Unfortunately it runs after downloading one sample in the issue below:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed

Arch Linux
Python 3.7.6 | packaged by conda-forge | (default, Mar 5 2020, 15:27:18)
geckodriver 0.26.0
Mozilla Firefox 74.0

Gisaid Scraper for Influenza

Were there any plans to expand this out to scraping information for influenza from GISAID? I haven't been able to find code for that, and I think this provides a template for that.

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.