示例#1
0
def _x3d(filename):
    import chimera
    title = ""
    try:
        chimera.viewer.x3dWrite(filename, title)
    except IOError, v:
        raise chimera.NonChimeraError("Error writing x3d file: " + str(v))
示例#2
0
def _exportSTL(filename):
    # Determine endian-ness
    import struct
    if struct.pack("h", 1) == "\000\001":
        big_endian = 1
    else:
        big_endian = 0
    if big_endian:
        raise chimera.NonChimeraError(
            "Only support STL output on little-endian computers")
    return _x3dConvert("x3d2stl", filename)
def _invoke(service, opts, pdb):
	import multipart
	try:
		return multipart.post_multipart(
				"helixweb.nih.gov",
				"/cgi-bin/structbio/basic",
				opts + [
				  ( "pdb_file", "chimera", pdb ),
				  ( "what", None, service ),
				  ( "outputtype", None, "Raw" ),
				]
				)
	except:
		raise chimera.NonChimeraError("Error contacting "
				"StrucTools web server")
示例#4
0
def _x3dConvert(prog, filename):
    import chimera, os
    title = ""
    prog = os.path.join(os.environ["CHIMERA"], "bin", prog)
    try:
        from SubprocessMonitor import Popen, PIPE
        cmd = [prog, '-o', filename]
        proc = Popen(cmd, stdin=PIPE)
        chimera.viewer.x3dWrite(proc.stdin, 0, title)
        proc.stdin.close()
        returncode = proc.wait()
        if returncode == 1:
            raise chimera.NonChimeraError("Error writing %s" % (filename))
        elif returncode != 0:
            raise RuntimeError("'%s' exited with error code %d" %
                               (prog, returncode))
    except chimera.error, v:
        raise chimera.UserError(v)
示例#5
0
# Colors and saves movies of a Chimera model from various angles

# Imports
import getopt, sys  # Allows for command line arguments
import os
import chimera
from chimera import runCommand as rc

try:
    opts, args = getopt.getopt(sys.argv[1:], '', [
        'rep=', 'test=', 'qID=', 'rID=', 'lengthID=', 'cutoff=', 'colorType=',
        'testType=', 'attr=', 'minVal=', 'maxVal=', 'frameCount='
    ])
except getopt.error as message:
    raise chimera.NonChimeraError(
        "%s: %s" % (__name__, message))  # Prints error if present

rep = ''
test = ''  # doesn't actually exist in GUI3 script
qID = ''
rID = ''
lengthID = ''  # amino acid count
cutoff = ''
colorType = ''  # rg, yb, or om
testType = ''  # flux or corr
attr = ''  # delta, pval, or stat
max_value = ''
min_value = ''
frame_count = ''

# Assigns option values to variables
示例#6
0
def make_mutants():
    try:
        opts, args = getopt.getopt(sys.argv[1:], '', [
            'rID=', 'outdir=', 'chain=', 'start=', 'end=', 'chainR=', 'startR='
        ])
    except getopt.error as message:
        raise chimera.NonChimeraError(
            "%s: %s" % (__name__, message))  # Prints error if present
    # initialize
    rID = ''
    outdir = ''
    chain = ''
    start = ''
    end = ''
    chainR = ''
    startR = ''

    # Assigns option values to variables
    for o, a in opts:
        if o == '--rID':
            rID = a
        if o == '--outdir':
            outdir = a
        if o == '--chain':
            chain = a
        if o == '--start':
            start = a
        if o == '--end':
            end = a
        if o == '--chainR':
            chainR = a
        if o == '--startR':
            startR = a

    # Ensures that all variables have been assigned and ends script if any are missing
    assert (len(rID) != 0)
    assert (len(outdir) != 0)
    assert (len(chain) != 0)
    assert (len(start) != 0)
    assert (len(end) != 0)
    assert (len(chainR) != 0)
    assert (len(startR) != 0)

    # open PDB file
    file_out = open('%s/mutants_chain%s.txt' % (outdir, chain), 'a')
    model = "1"
    pdb_file = "%s.pdb" % (rID)
    #out_dir = "%s" % (outdir)
    #pdb_file = "1zbb_bound.pdb"
    print(outdir)
    print(pdb_file)
    # redefine as integer
    start = int(start)
    end = int(end) + 1
    startR = int(startR)

    CapChain = chain.upper()

    for x in range(start, end):
        mol = chimera.openModels.open(pdb_file)[0]  # Opens molecule
        myres = mol.findResidue(x - 1)  # reads residue
        myres = str(myres)
        print("myres=%s" % myres)
        if (myres != "DA %s.%s" %
            (x, CapChain)):  # swap only if nucleotides differ
            rc("swapna A :%s.%s" % (x, chain))
            y = startR - x + 1
            rc("swapna T :%s.%s" % (y, chainR))
            rc("write 0 %s/%s_mutA%s_chain%s.pdb" % (outdir, rID, x, chain))
            file_out.write('%s_mutA%s_chain%s\n' % (rID, x, chain))
        rc("close 0")
        mol = chimera.openModels.open(pdb_file)[0]  # Opens molecule
        myres = mol.findResidue(x - 1)  # reads residue
        myres = str(myres)
        if (myres != "DT %s.%s" %
            (x, CapChain)):  # swap only if nucleotides differ
            rc("swapna T :%s.%s" % (x, chain))
            y = startR - x + 1
            rc("swapna A :%s.%s" % (y, chainR))
            rc("write 0 %s/%s_mutT%s_chain%s.pdb" % (outdir, rID, x, chain))
            file_out.write('%s_mutT%s_chain%s\n' % (rID, x, chain))
        rc("close 0")
        mol = chimera.openModels.open(pdb_file)[0]  # Opens molecule
        myres = mol.findResidue(x - 1)  # reads residue
        myres = str(myres)
        if (myres != "DC %s.%s" %
            (x, CapChain)):  # swap only if nucleotides differ
            rc("swapna C :%s.%s" % (x, chain))
            y = startR - x + 1
            rc("swapna G :%s.%s" % (y, chainR))
            rc("write 0 %s/%s_mutC%s_chain%s.pdb" % (outdir, rID, x, chain))
            file_out.write('%s_mutC%s_chain%s\n' % (rID, x, chain))
        rc("close 0")
        mol = chimera.openModels.open(pdb_file)[0]  # Opens molecule
        myres = mol.findResidue(x - 1)  # reads residue
        myres = str(myres)
        if (myres != "DG %s.%s" %
            (x, CapChain)):  # swap only if nucleotides differ
            rc("swapna G :%s.%s" % (x, chain))
            y = startR - x + 1
            rc("swapna C :%s.%s" % (y, chainR))
            rc("write 0 %s/%s_mutG%s_chain%s.pdb" % (outdir, rID, x, chain))
            file_out.write('%s_mutG%s_chain%s\n' % (rID, x, chain))
        rc("close 0")

    file_out.close()
    return rID, outdir, startR, chainR, chain, start, end
示例#7
0
def make_mutants():

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], '',
            ['rID=', 'outdir=', 'chain=', 'start=', 'end=', 'alnID=', 'Vnum='])
    except getopt.error as message:
        raise chimera.NonChimeraError(
            "%s: %s" % (__name__, message))  # Prints error if present

    # initialize
    rID = ''
    outdir = ''
    chain = ''
    start = ''
    end = ''
    alnID = ''
    Vnum = ''

    # Assigns option values to variables
    for o, a in opts:
        if o == '--rID':
            rID = a
        if o == '--outdir':
            outdir = a
        if o == '--chain':
            chain = a
        if o == '--start':
            start = a
        if o == '--end':
            end = a
        if o == '--alnID':
            alnID = a
        if o == '--Vnum':
            Vnum = a

    # Ensures that all variables have been assigned and ends script if any are missing
    assert (len(rID) != 0)
    assert (len(outdir) != 0)
    assert (len(chain) != 0)
    assert (len(start) != 0)
    assert (len(end) != 0)
    assert (len(alnID) != 0)
    assert (len(Vnum) != 0)

    # ctl directory
    indir = "%s_ctl" % (outdir)
    # open PDB
    file_out = open('%s/mutants_chain%s.txt' % (outdir, chain), 'a')
    model = "1"
    pdb_file = "%s.pdb" % (rID)
    #out_dir = "%s" % (outdir)
    #pdb_file = "1zbb_bound.pdb"
    aln_file = "%s.aln" % (alnID)
    print(outdir)
    print(pdb_file)
    print(aln_file)
    # redefine as integer
    start = int(start)
    end = int(end) + 1
    Vnum = int(Vnum)

    for x in range(1, Vnum + 1):
        mol = chimera.openModels.open(pdb_file)[0]  # Opens molecule
        rc('read ~/Desktop/%s/variant%s.com' % (indir, x))
        file_out.write('%s_variant%s_chain%s\n' % (rID, x, chain))
    # Close the file
    file_out.close()
    return rID, outdir, chain, start, end
示例#8
0
def make_mutants():

    try:
    	opts, args = getopt.getopt(sys.argv[1:], '', ['rID=', 'outdir=', 'chain=', 'start=', 'end='])
    except getopt.error as message:
        raise chimera.NonChimeraError("%s: %s" % (__name__, message)) # Prints error if present
    
    # initialize
    rID = ''
    outdir = ''
    chain = ''
    start = ''
    end = ''

    # Assigns option values to variables
    for o,a  in opts:
        if o == '--rID':
            rID = a
        if o == '--outdir':
            outdir = a
        if o == '--chain':
            chain = a
        if o == '--start':
            start = a
        if o == '--end':
            end = a
        
     # Ensures that all variables have been assigned and ends script if any are missing
    assert(len(rID) != 0)
    assert(len(outdir) != 0)
    assert(len(chain) != 0)
    assert(len(start) != 0)
    assert(len(end) != 0)
    # open PDB
    file_out = open('%s/mutants_chain%s.txt' % (outdir, chain), 'a' )
    model = "1"
    pdb_file = "%s.pdb" % (rID)
    #out_dir = "%s" % (outdir)
    #pdb_file = "1zbb_bound.pdb"
    print(outdir)
    print(pdb_file)
    # redefine as integer
    start = int(start)
    end = int(end)+1

    for x in range(start,end):
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa ALA :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutALA%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutALA%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa ARG :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutARG%s_chain%s.pdb\n" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutARG%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa ASN :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutASN%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutASN%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa ASP :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutASP%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutASP%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa CYS :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutCYS%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutCYS%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa GLU :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutGLU%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutGLU%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa GLN :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutGLN%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutGLN%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa GLY :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutGLY%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutGLY%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa HIS :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutHIS%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutHIS%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa ILE :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutILE%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutILE%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa LEU :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutLEU%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutLEU%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa LYS :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutLYS%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutLYS%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa MET :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutMET%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutMET%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa PHE :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutPHE%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutPHE%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa PRO :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutPRO%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutPRO%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa SER :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutSER%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutSER%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa THR :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutTHR%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutTHR%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa TRP :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutTRP%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutTRP%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa TYR :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutTYR%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutTYR%s_chain%s\n' % (rID, x, chain))
        mol = chimera.openModels.open(pdb_file)[0] # Opens molecule
        rc("swapaa VAL :%s.%s" % (x, chain))
        rc("write 0 %s/%s_mutVAL%s_chain%s.pdb" % (outdir, rID, x, chain))
        rc("close 0")
        file_out.write('%s_mutVAL%s_chain%s\n' % (rID, x, chain))

    # Close the file
    file_out.close()
    return rID, outdir, chain, start, end