Exemple #1
0
def install_blast(base_dir):
    """Deprecated, look into 'home_linux/setup/bioinfo_tools'
    On Ubuntu: sudo apt-get install ncbi-blast+
    """
    # Default location #
    if base_dir is None: base_dir = os.environ.get('HOME', '/') + '/programs/blast/'
    # Download from FTP #
    ftp_url = "ftp.ncbi.nlm.nih.gov"
    ftp_dir = "/blast/executables/blast+/LATEST/"
    pattern = 'ncbi-blast-*+-src.zip'
    ftp = FTPHost(ftp_url, "anonymous")
    ftp.chdir(ftp_dir)
    files = ftp.listdir(self.ftp.curdir)
    ftp.download(source, dest)
rmtdir = '/modelos/io/produtos/MERGE'  # diretorio remoto

for d in days:

    year = d[:4]

    binfile = 'prec_{0}.bin'.format(d)
    ctlfile = 'prec_{0}.ctl'.format(d)

    locbinfile = '{0}/{1}/{2}'.format(locdir, year, binfile)
    locctlfile = '{0}/{1}/{2}'.format(locdir, year, ctlfile)

    if not os.path.exists(locbinfile):

        msg = 'File not found: {0}'.format(locbinfile)
        print(msg)

        rmtbinfile = '{0}/{1}/{2}'.format(rmtdir, year, binfile)
        rmtctlfile = '{0}/{1}/{2}'.format(rmtdir, year, ctlfile)

        host = FTPHost(hostnm, usernm, passwd)

        host.download(rmtbinfile, locbinfile)  # remoto, local
        host.download(rmtctlfile, locctlfile)

    else:

        msg = 'File already exists: {0}'.format(locbinfile)
        print(msg)