Exemplo n.º 1
0
 def _executable(self):
     """ Create executable and mark it executable """
     from cadee.executables import exe
     exe = exe.which('qdyn5')
     if exe is None:
         raise 'qdyn5 not found'
     self.exe = exe
Exemplo n.º 2
0
def get_exec_path(name):
    #paths=[]
    #for path in os.environ["PATH"].split(os.pathsep):                       
    #    path=path.strip('"')                                                
    #    if not os.path.lexists(path):
    #        continue
    #    for ex in os.listdir(path):                                         
    #         if name in ex:                                              
    #              ex = os.path.join(path,ex)                                  
    #              if not ex in paths:
    #                  paths.append(ex)
    #
    #if not paths:
    #    print "No '%s' executable was found in your PATH. Please add the path to qfep to the config file manually." % name
    #else:
    #    print "These '%s' executables were found in your PATH. Choose the correct one or write the path.\n" % name
    #    for i,path in enumerate(paths):
    #        print "      [%d] %s" % (i, path)
    #    path=""
    #    while not path:
    #        try:
    #            inp=raw_input("? ")
    #            i=int(inp)
    #            path=paths[i]
    #        except ValueError:
    #            if inp:
    #                path=inp
    #        except IndexError:
    #            pass
    #    return path
    #return ""
    import cadee.executables.exe as exe
    path = exe.which(name)
    if path is None:
        path = exe.which(name+'5')
    if path is None:
        print('Binary not found: ', name)
        raise (Exception, 'Please install %s ', name)
    print(path)
    return path
Exemplo n.º 3
0
def run_scwrl(out_pdb, out_log, in_pdb, in_seq):
    """Run SCWRL4. Use 'Scwrl4' - executable from $PATH"""
    import cadee.executables.exe as exe

    scwrl_exe = exe.which('Scwrl4')
    if scwrl_exe is None:
        raise Exception("FATAL: 'Scwrl4' - executable not found.")

    scwrl_line = '{SCWRL} -i {SCWRL_PDB} -o {OUT} -s {SEQ} > {LOG}'
    cmd = scwrl_line.format(SCWRL=scwrl_exe,
                            SCWRL_PDB=in_pdb,
                            OUT=out_pdb,
                            LOG=out_log,
                            SEQ=in_seq)
    os.system(cmd)

    if not os.path.isfile(out_pdb):
        raise Exception("FATAL: 'Scwrl4' - executable did not create output!",
                        cmd)
Exemplo n.º 4
0
def babel_pdb_for_scwrl(wtpdb,
                        proper_pdb='proper.pdb',
                        proper_fasta='proper.fasta',
                        temp_pdb='temp.pdb',
                        sprss_babel=True):
    """ convert q-pdb to scwrl-compatible pdb """

    if sprss_babel:
        sprssbabel = '2>&1 | egrep -v "1 molecule converted|audit log messages"'  # NOPEP8
    else:
        sprssbabel = ''

    while os.path.exists(temp_pdb):
        temp_pdb += '.pdb'

    temp_pdb = '"' + temp_pdb + '"'

    import config
    import cadee.executables.exe as exe

    # locate babel-exe
    babel_exe = exe.which('babel')
    if babel_exe is None:
        raise Exception("FATAL: babel executable not found")

    # prepare list of renamed residues
    resren = ''
    for rren in config.RESRENAME:
        resren += 'sed -i "s/{0}/{1}/g" $f'.format(rren[0], rren[1]) + NLC
        if not rren[1] in config.NATURAL_AA:
            raise Exception('Can not replace ' + rren[0] + ' with' + rren[1] +
                            ' which is not recognized by scwrl4!)')  # NOPEP8

    if len(config.NATURAL_AA) < 1:
        raise Exception('Config is not OK. Check config.RESSCWRL4')

    allnat = 'egrep "^(ATOM|HETATM).*('

    for amino in config.NATURAL_AA:
        allnat += amino + '|'

    # kill the last |
    if allnat[-1] == '|':
        allnat = allnat[:-1]
    else:
        raise Exception('WTF')

    allnat += ')" ' + proper_pdb + ' > $f '

    cmd = """

f={TEMP_PDB}

{BABEL} -d ---errorlevel 0 {WT} $f  {SPRSSBABEL}

# convert all protonated residues into standard residues
{RESREN}

# kill protons
sed -i '/H  $/d' $f

# remove connect-records
sed -i '/CONECT/d' $f

mv $f {PROPER_PDB}

# kill everything that is not an natural amino acid
{ALLNAT}

{BABEL} ---errorlevel 1 $f {PROPER_PDB}  {SPRSSBABEL}

/bin/rm $f

{BABEL} ---errorlevel 1 {PROPER_PDB} {PROPER_FASTA} {SPRSSBABEL}

exit 0

""".format(WT=wtpdb,
           PROPER_PDB=proper_pdb,
           PROPER_FASTA=proper_fasta,
           TEMP_PDB=temp_pdb,
           BABEL=babel_exe,
           SPRSSBABEL=sprssbabel,
           RESREN=resren,
           ALLNAT=allnat)
    logger.debug(cmd)
    os.system(cmd)
Exemplo n.º 5
0
    print('       -OR-')
    print('       Ensure the binaries are in $PATH.'.format(exe))
    print()
    print('       Q6 can be obtained free of charge from {0}.'.format(
        'https://github.com/qusers/Q6'))
    installation_failed()


if not (sys.version_info[0] == 2 and sys.version_info[1] == 7):
    print('Need Python 2.7')
    installation_failed()

# There are many versions of executables named Qdyn6.
# CADEE should stick to one version, so include with the cadee installation.
for qexe in QEXES:
    if not exe.which(qexe, True):

        print('Warning: Could not find {0} in {1}'.format(qexe, qexedir))
        print('         Searching in $PATH...')
        print()
        if exe.which(qexe):
            print('         Found {0} in {1}.'.format(qexe, exe.which(qexe)))
            print()
            print('         Will now copy {0} to {1}.'.format(qexe, qexedir))

            # compatibility of python3 and python2
            try:
                input = raw_input
            except NameError:
                pass
            ans = input('           Proceed (y/N)?').lower()
Exemplo n.º 6
0
def get_executable(program):
    """Locate executable with name program"""
    program = exe.which(program)
    if program is None:
        raise Exception("Executable not found")
    return program