Пример #1
0
def installClustalw2OnWindows(tmpDirName, tmpFileName, guiParent=None):
    """
    Run the msi installer.
    """
    os.system(tmpFileName)

    if not findOnSystem('clustalw2.exe'):
        failiure(guiParent=guiParent, errorNr=6)
Пример #2
0
def installClustalw2OnWindows(tmpDirName, tmpFileName, guiParent=None):
    """
    Run the msi installer.
    """
    os.system(tmpFileName)

    if not findOnSystem("clustalw2.exe"):
        failiure(guiParent=guiParent, errorNr=6)
Пример #3
0
def assertBlastInstalled(guiParent=None):
    """
    Checks if Blast is installed.
    """

    #     # First check if the user has wu-blast installed:
    #     if findOnSystem('blastn') and findOnSystem('xdformat'):
    #         return True

    ftpURL = "ftp.ncbi.nlm.nih.gov"
    ftpDir = "/blast/executables/blast+/LATEST"

    found = False
    if os.name in ("nt", "dos"):
        name = "blastn.exe"
    else:
        name = "blastn"

    msg = (
        "This program depends on %s for searching databases. If you have an\ninternet connection SAP can download and install it for you.\nDo you  want to do this now?"
        % name
    )

    if findOnSystem(name):
        return True
    else:
        if guiParent is None:
            reply = prompt(msg + " Y/n:")
            if reply == "n":
                sys.exit()
        else:
            import wx

            nResult = wx.MessageBox(msg, "Depency missing from your system!", wx.YES_NO | wx.ICON_QUESTION, guiParent)
            if nResult == wx.NO:
                msg = "You can download Blast yourself from:\nftp://%s/%s" % (ftpURL, ftpDir)
                dlg = wx.MessageDialog(guiParent, msg, "Manual installation", wx.OK | wx.ICON_INFORMATION)
                dlg.ShowModal()
                dlg.Destroy()
                sys.exit()

        # packageRE = re.compile(r'ncbi-blast-[\d.]+\+-([^.]+)')
        packageRE = re.compile(r"(ncbi-blast-.+)")
        getPackage("blastn", packageRE, ftpURL, ftpDir, guiParent=guiParent)

        return True
Пример #4
0
def assertBlastInstalled(guiParent=None):
    """
    Checks if Blast is installed.
    """

    #     # First check if the user has wu-blast installed:
    #     if findOnSystem('blastn') and findOnSystem('xdformat'):
    #         return True

    ftpURL = 'ftp.ncbi.nlm.nih.gov'
    ftpDir = '/blast/executables/blast+/LATEST'

    found = False
    if os.name in ('nt', 'dos'):
        name = 'blastn.exe'
    else:
        name = 'blastn'

    msg = "This program depends on %s for searching databases. If you have an\ninternet connection SAP can download and install it for you.\nDo you  want to do this now?" % name

    if findOnSystem(name):
        return True
    else:
        if guiParent is None:
            reply = prompt(msg + ' Y/n:')
            if reply == 'n':
                sys.exit()
        else:
            import wx
            nResult = wx.MessageBox(msg, "Depency missing from your system!",
                                    wx.YES_NO | wx.ICON_QUESTION, guiParent)
            if nResult == wx.NO:
                msg = "You can download Blast yourself from:\nftp://%s/%s" % (
                    ftpURL, ftpDir)
                dlg = wx.MessageDialog(guiParent, msg, 'Manual installation',
                                       wx.OK | wx.ICON_INFORMATION)
                dlg.ShowModal()
                dlg.Destroy()
                sys.exit()

        #packageRE = re.compile(r'ncbi-blast-[\d.]+\+-([^.]+)')
        packageRE = re.compile(r'(ncbi-blast-.+)')
        getPackage('blastn', packageRE, ftpURL, ftpDir, guiParent=guiParent)

        return True
Пример #5
0
def installBlastOnWindows(tmpDirName, tmpFileName, guiParent=None):
    """
    Install downloaded package on a widows platform.
    """
    z = zipfile.ZipFile(tmpFileName, "r")
    for fileName in z.namelist():
        if fileName == 'blastall.exe':
            excecutable = z.read(fileName)
    z.close()
    installDir = 'C:\Program Files\Blast'
    os.makedirs(installDir)

    fh = open(os.path.join(installDir, 'blastall.exe'), 'wb')
    fh.write(excecutable)
    fh.close()

    if not findOnSystem('blastall.exe'):
        failiure(guiParent=guiParent, errorNr=4)
Пример #6
0
def installBlastOnWindows(tmpDirName, tmpFileName, guiParent=None):
    """
    Install downloaded package on a widows platform.
    """
    z = zipfile.ZipFile(tmpFileName, "r")
    for fileName in z.namelist():
        if fileName == "blastall.exe":
            excecutable = z.read(fileName)
    z.close()
    installDir = "C:\Program Files\Blast"
    os.makedirs(installDir)

    fh = open(os.path.join(installDir, "blastall.exe"), "wb")
    fh.write(excecutable)
    fh.close()

    if not findOnSystem("blastall.exe"):
        failiure(guiParent=guiParent, errorNr=4)
Пример #7
0
def assertClustalw2Installed(guiParent=None):
    """
    Checks if Clustalw2 is installed.
    """

    ftpURL = 'ftp.ebi.ac.uk'
    ftpDir = 'pub/software/clustalw2/2.0.8'

    found = False
    if os.name in ('nt', 'dos'):
        name = 'clustalw2.exe'
    else:
        name = 'clustalw2'

    msg = "This program depends on %s for aligning homologues. If you have an internet connection SAP\ncan download and install it for you. Do you  want to do this now?" % name
    if findOnSystem(name):
        return True
    else:
        if guiParent is None:
            reply = prompt(msg + ' Y/n:')
            if reply == 'n':
                sys.exit()
        else:
            import wx
            nResult = wx.MessageBox(msg,
                                    "Dependency missing from your system!",
                                    wx.YES_NO | wx.ICON_QUESTION, guiParent)
            if nResult == wx.NO:
                msg = "You can download %s yourself from:\nftp://%s/%s" % (
                    name, ftpURL, ftpDir)
                dlg = wx.MessageDialog(guiParent, msg, 'Manual installation',
                                       wx.OK | wx.ICON_INFORMATION)
                dlg.ShowModal()
                dlg.Destroy()
                sys.exit()

        packageRE = re.compile(r'clustalw-[\d.]+-([^.]+)')
        success = getPackage('clustalw2',
                             packageRE,
                             ftpURL,
                             ftpDir,
                             guiParent=guiParent)
        return success
Пример #8
0
def installBlastOnPosix(tmpDirName, tmpFileName, guiParent=None):
    """
    Install downloaded package on a posix platform.
    """

    # Unpack the tarball:
    tar = tarfile.open(tmpFileName, 'r:gz')

    for item in tar:
        tar.extract(item, tmpDirName)
    tar.close()
    os.unlink(tmpFileName)

    #     # Get content list:
    #     packageContent = glob.glob(os.path.join(tmpDirName, '*'))
    #     # Decend one dir level if tarball was unpacked to a dir:
    #     if len(packageContent) == 1 and os.path.isdir(packageContent[0]):
    #         packageContent = glob.glob(os.path.join(packageContent[0], '*'))
    packageContent = glob.glob(os.path.join(tmpDirName, 'ncbi-blast-*', '*'))

    installDir = getPossixInstallDir(guiParent=guiParent)

    # Chop off the bin dir from the install path becauce we copy the
    # bin dir and the data dir over when installing:
    installDir = os.path.split(installDir)[0]

    try:
        if not os.access(installDir, os.W_OK):
            if guiParent is None:
                os.system("sudo cp -r %s %s" %
                          (" ".join(packageContent), installDir))
            else:
                os.system("echo '%s' | sudo -S cp -r %s %s" %
                          (passwDialog(guiParent), " ".join(packageContent),
                           installDir))
        else:
            os.system("cp -r %s %s" % (" ".join(packageContent), installDir))
    except:
        pass

    if not findOnSystem('blastn'):
        failiure(guiParent=guiParent, errorNr=7)
Пример #9
0
def installBlastOnPosix(tmpDirName, tmpFileName, guiParent=None):
    """
    Install downloaded package on a posix platform.
    """

    # Unpack the tarball:
    tar = tarfile.open(tmpFileName, "r:gz")

    for item in tar:
        tar.extract(item, tmpDirName)
    tar.close()
    os.unlink(tmpFileName)

    #     # Get content list:
    #     packageContent = glob.glob(os.path.join(tmpDirName, '*'))
    #     # Decend one dir level if tarball was unpacked to a dir:
    #     if len(packageContent) == 1 and os.path.isdir(packageContent[0]):
    #         packageContent = glob.glob(os.path.join(packageContent[0], '*'))
    packageContent = glob.glob(os.path.join(tmpDirName, "ncbi-blast-*", "*"))

    installDir = getPossixInstallDir(guiParent=guiParent)

    # Chop off the bin dir from the install path becauce we copy the
    # bin dir and the data dir over when installing:
    installDir = os.path.split(installDir)[0]

    try:
        if not os.access(installDir, os.W_OK):
            if guiParent is None:
                os.system("sudo cp -r %s %s" % (" ".join(packageContent), installDir))
            else:
                os.system(
                    "echo '%s' | sudo -S cp -r %s %s" % (passwDialog(guiParent), " ".join(packageContent), installDir)
                )
        else:
            os.system("cp -r %s %s" % (" ".join(packageContent), installDir))
    except:
        pass

    if not findOnSystem("blastn"):
        failiure(guiParent=guiParent, errorNr=7)
Пример #10
0
def assertClustalw2Installed(guiParent=None):
    """
    Checks if Clustalw2 is installed.
    """

    ftpURL = "ftp.ebi.ac.uk"
    ftpDir = "pub/software/clustalw2/2.0.8"

    found = False
    if os.name in ("nt", "dos"):
        name = "clustalw2.exe"
    else:
        name = "clustalw2"

    msg = (
        "This program depends on %s for aligning homologues. If you have an internet connection SAP\ncan download and install it for you. Do you  want to do this now?"
        % name
    )
    if findOnSystem(name):
        return True
    else:
        if guiParent is None:
            reply = prompt(msg + " Y/n:")
            if reply == "n":
                sys.exit()
        else:
            import wx

            nResult = wx.MessageBox(
                msg, "Dependency missing from your system!", wx.YES_NO | wx.ICON_QUESTION, guiParent
            )
            if nResult == wx.NO:
                msg = "You can download %s yourself from:\nftp://%s/%s" % (name, ftpURL, ftpDir)
                dlg = wx.MessageDialog(guiParent, msg, "Manual installation", wx.OK | wx.ICON_INFORMATION)
                dlg.ShowModal()
                dlg.Destroy()
                sys.exit()

        packageRE = re.compile(r"clustalw-[\d.]+-([^.]+)")
        success = getPackage("clustalw2", packageRE, ftpURL, ftpDir, guiParent=guiParent)
        return success
Пример #11
0
def installClustalw2OnPosix(tmpDirName, tmpFileName, guiParent=None):

    installDir = getPossixInstallDir(guiParent=guiParent)

    fail = False

    if sys.platform == 'darwin':
        # Unpack the disk image and move the executable to the install dir:
        fail = os.system('open -g -a DiskImageMounter %s' % tmpFileName)

        # Hack to for OSX 10.4 where open does not have the -g option:
        if fail == 256:
            fail = os.system('open -a DiskImageMounter %s' % tmpFileName)

        if fail:
            return False
        while not glob.glob('/Volumes/clustalw-*/clustalw-*/clustalw2'):
            time.sleep(1)
        time.sleep(2)
        executable = glob.glob('/Volumes/clustalw-*/clustalw-*/clustalw2')[0]

        try:
            if not os.access(installDir, os.W_OK):
                if guiParent is None:
                    os.system("sudo cp %s %s" % (executable, installDir))
                else:
                    os.system("echo '%s' | sudo -S cp %s %s" %
                              (passwDialog(guiParent), executable, installDir))
            else:
                os.system("cp %s %s" % (executable, installDir))
        except:
            return False
    else:
        # Unpack the tarball:
        tar = tarfile.open(tmpFileName, 'r:gz')

        for item in tar:
            tar.extract(item, tmpDirName)
        tar.close()
        os.unlink(tmpFileName)

        # Chop off the bin dir from the install path becauce we copy the
        # bin dir and the data dir over when installing:
        installDir = os.path.split(installDir)[0]

        oldCWD = os.getcwd()
        os.chdir(glob.glob(tmpDirName + '/clustalw-*')[0])

        if installDir == '/usr/local':
            if os.system("./configure"):
                return False
        else:
            if os.system("./configure --prefix %s" % installDir):
                return False

        if os.system("make"):
            return False

        if not os.access(installDir, os.W_OK):
            if guiParent is None:
                os.system("sudo make install")
            else:
                os.system("echo '%s' | sudo -S make install")
        else:
            os.system("make install")

        os.chdir(oldCWD)

    if not findOnSystem('clustalw2'):
        failiure(guiParent=guiParent, errorNr=8)
Пример #12
0
def sap():

    try:

        optionsParser = Options.Options()
        options, args = optionsParser.postProcess()

        if options.viewresults:
            try:
                webbrowser.open('file://' + os.path.abspath(
                    os.path.join(options.viewresults, 'html', 'index.html')),
                                new=2,
                                autoraise=1)
            except:
                if os.path.exists(options.viewresults):
                    print "The anlysis has not completed and no results are available."
                else:
                    print "The spcified project folder does not exist."
            sys.exit()

        if options.compile:
            if os.path.exists(options.database):
                print "Database already exists. Delete old database or use other name."
                sys.exit()
            from CompileDatabase import compileDatabase
            compileDatabase(options.compile, options.email, options.database)
            sys.exit()

        if options.installdependencies:
            print "Checking that dependencies are installed on your system."

            from UtilityFunctions import findOnSystem
            missing = False
            if os.name in ('nt', 'dos'):
                name = 'blastn.exe'
            else:
                name = 'blastn'
            if not findOnSystem(name):
                print "\nThis program depends on %s for searching databases. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST\n\n" % name
                missing = True
            if os.name in ('nt', 'dos'):
                name = 'clustalw2.exe'
            else:
                name = 'clustalw2'
            if not findOnSystem(name):
                print "\nThis program depends on %s for aligning homologues. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ebi.ac.uk/pub/software/clustalw2/2.0.8\n\n" % name
                missing = True
            if not missing:
                print "You should be good to go."
#             if assertClustalw2Installed() and  assertBlastInstalled():
#                 print "All dependencies are installed"
#             #sys.exit()
            return None

        if options.onlinehelp:
            webbrowser.open(
                'http://kaspermunch.wordpress.com/statistical-assignment-package-sap/',
                new=2,
                autoraise=1)
            #sys.exit()
            return None

        # Make a string of all options except of the ones with a '_'
        # prefix which are for internal use only:
        optionStr = ''
        for k, v in options.__dict__.items():
            if not re.match('_', k):
                if type(v) is ListType:
                    if len(v) > 0:
                        joinString = ' --%s ' % k
                        v = [str(x) for x in v]
                        optionStr += joinString + joinString.join(v)
                elif v is True:
                    optionStr += ' --%s' % k
                elif v is not False:
                    optionStr += ' --%s %s' % (k, v)

        if options._align:
            try:
                plugin = findPlugin(options.alignment, 'sap.alignment')
            except PluginNotFoundError, X:
                raise AnalysisTerminated(
                    1, "The plugin or file %s was not found." % X.plugin)
            aligner = plugin.Aligner(options)
            for fastaFileName in args:
                aligner.align(fastaFileName)
        elif options._sample:
            try:
                plugin = findPlugin(options.assignment, 'sap.assignment')
            except PluginNotFoundError, X:
                raise AnalysisTerminated(
                    1, "The plugin or file %s was not found." % X.plugin)
Пример #13
0
#             #######################################
#             if options.ghostpopulation:
#                 ima = IMa.Assignment(options)
#                 ima.run(args)
#             #######################################

        else:

            # Check that netblast and clustalw2 are installed:
            from UtilityFunctions import findOnSystem
            missing = False
            if os.name in ('nt', 'dos'):
                name = 'blastn.exe'
            else:
                name = 'blastn'
            if not findOnSystem(name):
                print "\nThis program depends on %s for searching databases. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST\n\n" % name
                missing = True
            if os.name in ('nt', 'dos'):
                name = 'clustalw2.exe'
            else:
                name = 'clustalw2'
            if not findOnSystem(name):
                print "\nThis program depends on %s for aligning homologues. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ebi.ac.uk/pub/software/clustalw2/2.0.8\n\n" % name
                missing = True
            if missing:
                return None
#
#             print "Locating dependencies"
#             assertClustalw2Installed()
#             assertBlastInstalled()
Пример #14
0
def installClustalw2OnPosix(tmpDirName, tmpFileName, guiParent=None):

    installDir = getPossixInstallDir(guiParent=guiParent)

    fail = False

    if sys.platform == "darwin":
        # Unpack the disk image and move the executable to the install dir:
        fail = os.system("open -g -a DiskImageMounter %s" % tmpFileName)

        # Hack to for OSX 10.4 where open does not have the -g option:
        if fail == 256:
            fail = os.system("open -a DiskImageMounter %s" % tmpFileName)

        if fail:
            return False
        while not glob.glob("/Volumes/clustalw-*/clustalw-*/clustalw2"):
            time.sleep(1)
        time.sleep(2)
        executable = glob.glob("/Volumes/clustalw-*/clustalw-*/clustalw2")[0]

        try:
            if not os.access(installDir, os.W_OK):
                if guiParent is None:
                    os.system("sudo cp %s %s" % (executable, installDir))
                else:
                    os.system("echo '%s' | sudo -S cp %s %s" % (passwDialog(guiParent), executable, installDir))
            else:
                os.system("cp %s %s" % (executable, installDir))
        except:
            return False
    else:
        # Unpack the tarball:
        tar = tarfile.open(tmpFileName, "r:gz")

        for item in tar:
            tar.extract(item, tmpDirName)
        tar.close()
        os.unlink(tmpFileName)

        # Chop off the bin dir from the install path becauce we copy the
        # bin dir and the data dir over when installing:
        installDir = os.path.split(installDir)[0]

        oldCWD = os.getcwd()
        os.chdir(glob.glob(tmpDirName + "/clustalw-*")[0])

        if installDir == "/usr/local":
            if os.system("./configure"):
                return False
        else:
            if os.system("./configure --prefix %s" % installDir):
                return False

        if os.system("make"):
            return False

        if not os.access(installDir, os.W_OK):
            if guiParent is None:
                os.system("sudo make install")
            else:
                os.system("echo '%s' | sudo -S make install")
        else:
            os.system("make install")

        os.chdir(oldCWD)

    if not findOnSystem("clustalw2"):
        failiure(guiParent=guiParent, errorNr=8)
Пример #15
0
def sap():

    try:

        optionsParser = Options.Options()
        options, args = optionsParser.postProcess()

        if options.viewresults:
            try:
                webbrowser.open('file://' + os.path.abspath(os.path.join(options.viewresults, 'html', 'index.html')), new=2, autoraise=1)
            except:
                if os.path.exists(options.viewresults):
                    print "The anlysis has not completed and no results are available."
                else:
                    print "The spcified project folder does not exist."
            sys.exit()

        if options.compile:
            if os.path.exists(options.database):
                print "Database already exists. Delete old database or use other name."
                sys.exit()
            from CompileDatabase import compileDatabase
            compileDatabase(options.compile, options.email, options.database)
            sys.exit()

        if options.installdependencies:
            print "Checking that dependencies are installed on your system."

            from UtilityFunctions import findOnSystem
            missing = False
            if os.name in ('nt', 'dos'):
                name = 'blastn.exe'
            else:
                name = 'blastn'
            if not findOnSystem(name):
                print "\nThis program depends on %s for searching databases. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST\n\n" % name
                missing = True
            if os.name in ('nt', 'dos'):
                name = 'clustalw2.exe'
            else:
                name = 'clustalw2'
            if not findOnSystem(name):
                print "\nThis program depends on %s for aligning homologues. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ebi.ac.uk/pub/software/clustalw2/2.0.8\n\n" % name
                missing = True
            if not missing:
                print "You should be good to go."
#             if assertClustalw2Installed() and  assertBlastInstalled():
#                 print "All dependencies are installed"
#             #sys.exit()
            return None

        if options.onlinehelp:
            webbrowser.open('http://kaspermunch.wordpress.com/statistical-assignment-package-sap/', new=2, autoraise=1)
            #sys.exit()
            return None

        # Make a string of all options except of the ones with a '_'
        # prefix which are for internal use only:
        optionStr = ''
        for k, v in options.__dict__.items():
            if not re.match('_', k):
                if type(v) is ListType:
                    if len(v) > 0:
                        joinString = ' --%s ' % k
                        v = [str(x) for x in v]
                        optionStr += joinString + joinString.join(v)
                elif v is True:
                    optionStr += ' --%s' % k
                elif v is not False:
                    optionStr += ' --%s %s' % (k, v)

        if options._align:
            try:
                plugin = findPlugin(options.alignment, 'sap.alignment')
            except PluginNotFoundError, X:
                raise AnalysisTerminated(1, "The plugin or file %s was not found." % X.plugin)
            aligner = plugin.Aligner(options)
            for fastaFileName in args:
                aligner.align(fastaFileName)
        elif options._sample:
            try:
                plugin = findPlugin(options.assignment, 'sap.assignment')
            except PluginNotFoundError, X:
                raise AnalysisTerminated(1, "The plugin or file %s was not found." % X.plugin)
Пример #16
0
#             #######################################
#             if options.ghostpopulation:
#                 ima = IMa.Assignment(options)
#                 ima.run(args)
#             #######################################

        else:

            # Check that netblast and clustalw2 are installed:
            from UtilityFunctions import findOnSystem
            missing = False
            if os.name in ('nt', 'dos'):
                name = 'blastn.exe'
            else:
                name = 'blastn'
            if not findOnSystem(name):
                print "\nThis program depends on %s for searching databases. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ncbi.nlm.nih.gov/blast/executables/blast+/LATEST\n\n" % name
                missing = True
            if os.name in ('nt', 'dos'):
                name = 'clustalw2.exe'
            else:
                name = 'clustalw2'
            if not findOnSystem(name):
                print "\nThis program depends on %s for aligning homologues. Automatic installation is not longer supported. You need to install this yourself from:\nftp.ebi.ac.uk/pub/software/clustalw2/2.0.8\n\n" % name
                missing = True
            if missing:
                return None
#
#             print "Locating dependencies"
#             assertClustalw2Installed()
#             assertBlastInstalled()