Connect with us

Bioinformatics Programming

How to download files from an FTP server using Python?

Published

on

How to download files from an FTP server using Python?

In this article, we provide a simple Python script to download files from an FTP server using Python.

Write the FTP address and your username and password in the place specified below. Save this file in Python format (for example, download.py) and run it as:

$ python3 download.py



#!/usr/bin/env python3

import fnmatch
from ftplib import FTP

ftp = FTP('ftp address')

#if no username and password is required.
ftp.login()

#if username and password is required.         
ftp.login('your-username','your-password')    

# if you have to change directory on FTP server.
ftp.cwd('/path/to/dir/')

# Get all files
files = ftp.nlst()

# Download files
for file in files:
    if fnmatch.fnmatch(file, '*.tar.gz'):   #To download specific files.
        print("Downloading..." + file)

        try:
            ftp.retrbinary("RETR " + file ,open("/path/to/dir/on/your/local/system/" + file, 'wb').write)

        except EOFError:    # To avoid EOF errors.
            pass

ftp.close()


Dr. Muniba is a Bioinformatician based in New Delhi, India. She has completed her PhD in Bioinformatics from South China University of Technology, Guangzhou, China. She has cutting edge knowledge of bioinformatics tools, algorithms, and drug designing. When she is not reading she is found enjoying with the family. Know more about Muniba

Bioinformatics Programming

vs_analysis_compound.py: Python script to search for binding affinities based on compound names.

Published

on

vs_analysis_compound.py: Python script to search for binding affinities based on compound names.

Previously, we have provided the vs_analysis.py script to analyze virtual screening (VS) results obtained from Autodock Vina. In this article, we have provided another script to search for binding affinity associated with a compound. (more…)

Continue Reading

Bioinformatics Programming

How to convert the PDB file to PSF format?

Published

on

How to convert the PDB file to PSF format?

VMD allows converting PDB to PSF format but sometimes it gives multiple errors. Therefore, in this article, we are going to convert PDB into PSF format using a different method. (more…)

Continue Reading

Bioinformatics Programming

smitostr.py: Python script to convert SMILES to structures.

Published

on

smitostr.py: Python script to convert SMILES to structures.

As mentioned in some of our previous articles, RDKit provides a wide range of functions. In this article, we are using RDKit [1] to draw a molecular structure using SMILES. (more…)

Continue Reading

LATEST ISSUE

ADVERT