Exemplo n.º 1
0
def main():
    pir_path = sys.argv[1]
    query_id = sys.argv[2]
    template_id = sys.argv[3]
    atom_files_dir = sys.argv[4]
    conv_modres = False
    if len(sys.argv) == 6 and sys.argv[5] in ['true']:
        conv_modres = True

    env = environ()
    env.io.atom_files_directory.append(atom_files_dir)
    env.io.convert_modres = conv_modres

    auto = automodel(env, alnfile=pir_path, knowns=[template_id], sequence=query_id)
    auto.make()

    # for f in glob.glob(query_id + ".V*"):
    #     os.remove(f)
    # for f in glob.glob(query_id + ".D*"):
    #     os.remove(f)
    # for f in glob.glob(query_id + ".ini"):
    #     os.remove(f)
    # for f in glob.glob(query_id + ".rsr"):
    #     os.remove(f)
    # for f in glob.glob(query_id + ".sch"):
    #     os.remove(f)
    # for f in glob.glob(query_id + ".B*.pdb"):
    #     shutil.copy(f, os.path.dirname(pir_path) + '/' + query_id + '.pdb')
    #     os.remove(f)
    for f in glob.glob(os.path.splitext(__file__)[0] + '.log'):
        shutil.copy(f, os.path.curdir + '/modeller.log')
        os.remove(f)
Exemplo n.º 2
0
def pdb_cleaner(best_struct, path_ali, code):

    dir = os.getcwd()
    os.chdir(path_ali)

    global chain_to_use
    chain_to_use = best_struct[1].split("/")[-1].split(".")[0].split("_")[1]

    log.verbose()
    env = environ()

    env.io.hetatom = True
    io_data.hetatm = True

    env.io.atom_files_directory = [path_ali]

    a = automodel(
        env,
        alnfile=path_ali + best_struct[1].split("/")[-1].split(".")[0] +
        "_dummy_ali.pir",
        knowns=code + "_" + chain_to_use,
        sequence=best_struct[1].split("/")[-1].split(".")[0].split("_")[0])

    a.starting_model = 1
    a.ending_model = 1

    a.make()

    os.chdir(path_ali)
Exemplo n.º 3
0
    def modeling(self, aln_file, frag):
        chdir(path.join(self.cwd, 'MODEL/'))
        self.env.io.atom_files_directory = [
            './', self.cwd, self.absolute_pth,
            path.join(self.cwd, 'MODEL/')
        ]
        engine = automodel(
            self.env,
            alnfile=path.join(self.cwd, aln_file),
            knowns=self.pdb_in + '.pdb',  # codes of the templates
            sequence=frag[0],
            assess_methods=(assess.DOPE, assess.GA341))
        engine.starting_model = 1
        engine.ending_model = 1
        # start the engine
        engine.make()
        # Get a list of all successfully built models from the model engine.outputs
        models = list(filter(lambda x: x['failure'] is None, engine.outputs))
        models = models[0]

        filelist = [f for f in listdir(".") if f.endswith(".pdb")]
        for f in filelist:
            if f != models['name']:
                remove(f)
        return (models['name'], models['DOPE score'])
Exemplo n.º 4
0
def build_single_model(aln,known,seq,total_models):
	a = automodel(env, alnfile=aln,
				knowns=known, sequence=seq,
				assess_methods=(assess.DOPE,assess.GA341))
	a.starting_model = 1
	a.ending_model = int(total_models)
	a.make()
Exemplo n.º 5
0
def main():
    args = parse_args()
    aln_file = args.alignment
    target = args.target
    known = tuple(args.templates)
    check_pdb(target[0:4])
    n_structures = args.structures
    starting_point = args.starting_point
    for t in args.templates:
        check_pdb(t[0:4])

    # log.verbose()  # request verbose output
    env = environ()  # create a new MODELLER environment to build this model in

    # directories for input atom files
    env.io.atom_files_directory = ['.', '../atom_files']
    # env.io.hetatm = True
    a = automodel(env,
                  alnfile=aln_file,  # alignment filename
                  knowns=known,  # codes of the templates
                  sequence=target,
                  inifile=starting_point)  # code of the target
    a.starting_model = 1  # index of the first model
    a.ending_model = n_structures  # index of the last model
    # (determines how many models to calculate)
    a.make()
Exemplo n.º 6
0
def make_model(output_folder, interaction_pdb_folder, fasta):
    #detect pir file
    templates = list()
    for interaction_file in os.listdir(interaction_pdb_folder):
        if "SEPARED" in os.path.basename(interaction_file):
            templates.append(interaction_file)
            shutil.copyfile( os.path.join(interaction_pdb_folder, interaction_file) , os.path.join(output_folder, interaction_file) )

    os.chdir(output_folder)
    log.verbose()    # request verbose output
    env = environ()  # create a new MODELLER environment to build this model in

    # directories for input atom files
    env.io.atom_files_directory = ['.', '../atom_files']
    pir_file = glob.glob("*.pir")[0]
    env.io.hetatm=True

    a = automodel(env,
                alnfile  = pir_file, # alignment filename
                knowns   = tuple(templates),     # codes of the templates
                sequence = str(os.path.splitext(os.path.basename(fasta))[0].strip()))       

    a.starting_model= 1                 # index of the first model
    a.ending_model  = 1                 # index of the last model

    a.make()                            # do the actual homology modeling
Exemplo n.º 7
0
def modeller_automodel(pir_path, template_id, query_id, atom_files_dir):
    env = environ()
    env.io.atom_files_directory.append(atom_files_dir)
    env.io.convert_modres = False

    try:
        auto = automodel(env, alnfile=pir_path, knowns=[template_id], sequence=query_id)
        auto.make()
    except Exception as e:
        logging.info(e)

    for f in glob.glob(query_id + ".B*.pdb"):
        shutil.copy(f, os.path.splitext(pir_path)[0] + ".pdb")
        os.remove(f)
    for f in glob.glob(query_id + ".V*"):
        os.remove(f)
    for f in glob.glob(query_id + ".D*"):
        os.remove(f)
    for f in glob.glob(query_id + ".ini"):
        os.remove(f)
    for f in glob.glob(query_id + ".rsr"):
        os.remove(f)
    for f in glob.glob(query_id + ".sch"):
        os.remove(f)
    for f in glob.glob(os.path.splitext(__file__)[0] + '.log'):
        shutil.copy(f, os.path.splitext(pir_path)[0] + '.log')
        os.remove(f)
Exemplo n.º 8
0
def _patch_model(fbasename, seq_name):
    print(">> patching model...")
    log.verbose()
    env = environ()
    env.io.atom_files_directory = ['.', '../atom_files']
    a = automodel(
        env,
        # file with template codes and target sequence
        alnfile='trimmed_align.ali',
        # PDB codes of the templates
        knowns=fbasename,
        # code of the target
        sequence=fbasename.lower(),
        assess_methods=(assess.DOPE, assess.GA341))
    a.md_level = refine.fast  #very_fast, fast, slow, very_slow, slow_large, refine
    #repeat whole cycle twice and do not stop unless obj. func > 1e6
    #a.repeat_optimization = 2
    a.max_molpdf = 1e6
    a.make()

    pdb_out = "%s_PATCHED.pdb" % fbasename
    myCmd_mv = 'mv %s.B99990001.pdb %s' % (fbasename.lower(), pdb_out)
    os.system(myCmd_mv)

    return pdb_out
Exemplo n.º 9
0
def generate_model(target, template, arg_cwd):
    global cwd
    cwd = arg_cwd
    if target == template:
        return
    alnfile = cwd + '/cache/data/' + target + '_' + template + '.ali'
    if not os.path.isfile(alnfile):
        sys.stderr.write("NO ALN FILE: " + alnfile)
        sys.exit(228)
    log.verbose()
    env = environ()
    env.io.atom_files_directory = ['.', cwd + '/cache/data']
    a = automodel(env,
                  alnfile  = alnfile,
                  knowns   = template,
                  sequence = target)
    a.starting_model= 1
    a.ending_model  = 1
    a.make()

    os.rename(target + '.B99990001.pdb', cwd + '/cache/data/' + target + '.model' + template + '.pdb')
    rmsd = get_rmsd(target, target + '.model' + template)

    directory = cwd + '/cache/models/' + target + '/' + rmsd + '/'
    if not os.path.exists(directory):
        os.makedirs(directory)

    os.rename(cwd + '/cache/data/' + target + '.model' + template + '.pdb', directory + template + '.pdb')
    console("pigz --best -f -q " +  directory + template + '.pdb')
    os.remove(target + '.D00000001')
    os.remove(target + '.ini')
    os.remove(target + '.rsr')
    os.remove(target + '.sch')
    os.remove(target + '.V99990001')
Exemplo n.º 10
0
def _full_align(fbasename):
    pir_fname = fbasename + '.pir'
    seq_fname = fbasename + '.seq'
    f = open(pir_fname, "r")
    f1 = f.readlines()
    f.close()
    #f1 = [x.rstrip() for x in f1]
    for i in range(len(f1)):
        if ("P1;" in f1[i]):
            seq_name = f1[i][4:8]
        if ("sequence:" in f1[i]):
            seq_pos = i
    P1 = ">P1;" + seq_name + "\n"
    seq_line = "sequence:" + seq_name + ":::::::-1.00:-1.00\n"
    AA_block = ''.join([str(elem) for elem in f1[seq_pos + 1:]])
    seq_block = P1 + seq_line + AA_block
    f = open(pir_fname, 'w')
    f.writelines(seq_block)
    f.close()

    myCmd_A = 'cat %s %s > alignment.seg' % (pir_fname, seq_fname)
    os.system(myCmd_A)

    env = environ()
    env.io.atom_files_directory = ['.', '../atom_files']
    a = automodel(
        env,
        # file with template codes and target sequence
        alnfile='alignment.seg',
        # PDB codes of the templates
        knowns=fbasename,
        # code of the target
        sequence=seq_name)
    a.auto_align()  # get an automatic alignment (alignment.seg.ali)
    return seq_name
Exemplo n.º 11
0
def main():

    input_file = args_.input_argument
    output_file = args_.output_argument

    align_file = input_file[0]  # .ali file containing seq and pdb names
    all_info = align_file.split('/')[-1]
    seq = all_info.split('-')[0]  # query name
    pdb = all_info.split('-')[1].split('.')[0].split(':')  # pdb name
    sys.stdout = open(output_file[0], 'w')  # log file name

    env = environ()
    # Read in HETATM records from template PDBs
    env.io.hetatm = True

    a = automodel(
        env,
        alnfile=align_file,
        knowns=tuple(pdb),
        sequence=seq,
        assess_methods=(
            assess.DOPE,
            #soap_protein_od.Scorer(),
            assess.GA341))
    a.starting_model = 1
    a.ending_model = 20
    a.make()
Exemplo n.º 12
0
def run_automodel(input_dict, num_models:int=5):
    """
    :param input_dict: {query, alignment_file, template_code, num_models}
    :return: best model
    """

    query = input_dict['sequence']
    alignment_file = input_dict['aln_file']
    template_code = input_dict['knowns']

    a = automodel(env, alnfile=alignment_file,
                  knowns=template_code, sequence=query,
                  assess_methods=(assess.DOPE,
                                  assess.GA341))
    a.starting_model = 1
    a.ending_model = int(num_models)
    a.make()

    # Get a list of all successfully built models from a.outputs
    ok_models = [x for x in a.outputs if x['failure'] is None]
    # Rank the models by DOPE score
    key = 'DOPE score'
    if sys.version_info[:2] == (2, 3):
        ok_models.sort(lambda a, b: cmp(a[key], b[key]))
    else:
        ok_models.sort(key=lambda a: a[key])

    # Get top model
    m = ok_models[0]

    print("Top model: %s (DOPE score %.3f)" % (m['name'], m[key]))
    return(m['name'])

    return()
Exemplo n.º 13
0
def create_nucleosome(outfile, save_chain=None, **chains):
    """Homology model a complete nucleosome particle

    Parameters:
    -----------
    outfile: File-like object
        Where to write the output.
    save_chain: str
        Save only the strucutre from chain with name save_chain.
    chains: key, value pairs
        key is chain name, value is sequence to model

    Return:
    -------
    A file is written to outfile
    """
    chain_names = "ABCDEFGH"
    template = {
        sequence.id.split("_")[1]: sequence
        for sequence in SeqIO.parse()
    }

    seq_aln = {}
    for chain_name, template_seq in template:
        template_seq.id = "template"
        if chain not in chains:
            chain = template[chain]

        # If chain was not specified in input, just use sequence from template
        input_chain = SeqRecord(Seq(
            chains.get(chain_name, template_seq.seq.tostr())),
                                id="model")

        seqlist = [chain_seq, input_chain]
        aln_pir = L_fasta2pir.aln(muscle_aln(seqlist))
        aln_pir.add_pir_info('template', 'structureX', 'template_nucleosome',
                             'FIRST', i, 'LAST', i)
        aln_pir.add_pir_info('model', 'sequence', 'model_nucleosome')
        seq_aln[chain_name] = aln_pir

    mult_aln = L_fasta2pir.aln_mult_chains(list(seq_aln.values()))
    mult_aln.write('aln.pir')

    # Now let's do MODELLER
    env = environ()  # create a new MODELLER environment to build this model in
    env.io.atom_files_directory = [os.path.sep, "HistoneDB"]

    a = automodel(env, alnfile='aln.pir', knowns='template', sequence='model')
    a.starting_model = 1
    a.ending_model = 1
    a.rand_method = None
    a.max_sc_mc_distance = 10
    a.max_sc_sc_distance = 10
    a.md_level = None  # We will do MD anyway, and the structurea are similar.

    a.make()
Exemplo n.º 14
0
def model_maker(env, tmp, targ):
    """Generate a structure model using satisfaction of spatial restraints"""
    a = automodel(env,
                  alnfile=targ + '-' + tmp + '.ali',
                  knowns=tmp,
                  sequence=targ,
                  assess_methods=(assess.DOPE, assess.GA341))
    a.starting_model = 1
    a.ending_model = 5
    a.make()
Exemplo n.º 15
0
def simple_model(alignment,
                 instances,
                 output=None,
                 optimize=False,
                 verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    a = automodel(
        env,  # Loading the environment
        alnfile=alignment,  # Assigning the PIR alignment
        knowns=contents['str'],  # Listing the known structures
        sequence=contents['seq'],  # Identify the Query Sequence
        assess_methods=(assess.DOPE, assess.GA341,
                        assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')
Exemplo n.º 16
0
    def blank_model_modelisation(self):

        print "### Blank model ###"
        env = environ()
        env.io.hetatm = True  ## accept BLK residues and ligand
        a = automodel(env,
                      alnfile='resultat.ali',
                      knowns=self.pdb_template,
                      sequence=self.sequence_name,
                      assess_methods=(assess.DOPE, assess.GA341))
        a.starting_model = 1
        a.ending_model = 1
        a.make()

        self.DOPE_blank = a.outputs[0]["DOPE score"]
        self.molpdf_blank = a.outputs[0]["molpdf"]

        os.mkdir("blank_model")
        shutil.copyfile(self.sequence_name + ".B99990001.pdb",
                        "blank_model/blank.pdb")
        shutil.move(self.sequence_name + ".B99990001.pdb", "blank.pdb")

        self.pdb_blank = "blank_model/blank"
        self.pdb_filename_blank = "%s.pdb" % self.pdb_blank

        self.blank_model = my_model(self.pdb_filename_blank, self.seq_model,
                                    self.seq_template, self.sequence_name,
                                    None)
        self.blank_model.color_conservation(
        )  ## make the pdb file colored by conservation

        ## Same for template
        my_model(self.pdb_template + ".pdb",
                 self.seq_template,
                 self.seq_model,
                 self.pdb_template,
                 None,
                 _type="xray").color_conservation()

        move_files("blank_model")
        #clean_tempfile()

        print "INNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN"

        env.io.hetatm = True  ## accept BLK residues and ligand
        ## alignment between blank model structure and blank model sequence for next modelisation
        aln = alignment(env)
        mdl = model(env, file='blank.pdb')
        aln.append_model(mdl,
                         align_codes='blank_model',
                         atom_files='blank.pdb')
        aln.append(file=self.sequence_filename, align_codes=self.sequence_name)
        aln.align2d()
        aln.write(file='resultat_final.ali', alignment_format='PIR')
Exemplo n.º 17
0
def make_automodel():
    env = environ()
    env.io.hetatm = True
    a = automodel(
        env,
        alnfile=ALI_PATH,  #PIR format alignment
        knowns=REF_PROT_NAME,
        sequence=PROT_NAME,
        assess_methods=(assess.DOPE, assess.GA341))
    a.starting_model = START
    a.ending_model = END
    a.make()
def main():

    args = parse_arguments()
    env = environ()
    a = automodel(env,
                  alnfile=args.alignment,
                  knowns=args.template,
                  sequence=args.sequence,
                  assess_methods=(assess.DOPE, assess.GA341))
    a.starting_model = 1
    a.ending_model = args.n_models
    a.make()
Exemplo n.º 19
0
    def buildModel(self):
        from modeller.automodel import *

        env = environ()
        env.io.atom_files_directory=['.',"atom_files"]
        a = automodel(env, alnfile = self.alignFile_ali,
                      knowns=self.selectPdbName+self.selectPdbChain,
                      sequence=self.targetPdbName,
                      assess_methods=assess.DOPE)
        a.starting_mode = 1
        a.ending_model =5
        a.make()
Exemplo n.º 20
0
def create_nucleosome(outfile, save_chain=None, **chains):
	"""Homology model a complete nucleosome particle

	Parameters:
	-----------
	outfile : File-like object
		Where to write the output.
	save_chain : str
		Save only the strucutre from chain with name save_chain.
	chains: key, value pairs
		key is chain name, value is sequence to model

	Return:
	-------
	A file is written to outfile
	"""
	chain_names = "ABCDEFGH"
	template = {sequence.id.split("_")[1]: sequence for sequence in SeqIO.parse()}

	seq_aln = {}
	for chain_name, template_seq in template:
		template_seq.id = "template"
		if chain not in chains:
			chain = template[chain]

		#If chain was not specified in input, just use sequence from template
		input_chain = SeqRecord(Seq(chains.get(chain_name, template_seq.seq.tostr())), id="model")

		seqlist = [chain_seq,input_chain]
		aln_pir = L_fasta2pir.aln(muscle_aln(seqlist))
		aln_pir.add_pir_info('template','structureX','template_nucleosome', 'FIRST', i,'LAST',i)
		aln_pir.add_pir_info('model','sequence','model_nucleosome')
		seq_aln[chain_name] = aln_pir

	mult_aln=L_fasta2pir.aln_mult_chains(seq_aln.values())
	mult_aln.write('aln.pir')

	#Now let's do MODELLER
	env = environ()  # create a new MODELLER environment to build this model in
	env.io.atom_files_directory = [os.path.sep, "HistoneDB"]
	
	a = automodel(env,
              	  alnfile  = 'aln.pir',
                  knowns   = 'template',
                  sequence = 'model')
	a.starting_model= 1
	a.ending_model  = 1
	a.rand_method=None
	a.max_sc_mc_distance=10
	a.max_sc_sc_distance=10
	a.md_level=None # We will do MD anyway, and the structurea are similar.

	a.make()
Exemplo n.º 21
0
def _full_multi_align(fbasename):  # align the seq from *.pdb and RCSB_fasta

    log.verbose()
    env = environ()
    # directories for input atom files
    env.io.atom_files_directory = ['.', '../atom_files']
    a = automodel(
        env,
        # file with template codes and target sequence
        alnfile='alignment.seg',
        # PDB codes of the templates (structureX section) in alignment.seg
        knowns=fbasename,
        # code of the target (sequence section) in alignment.seg
        sequence=fbasename.lower())
    a.auto_align()  # get an automatic alignment

    # replace '-' with '/' after chain in the alignment.seg.ali file.
    align_file = "alignment.seg.ali"
    f = open(align_file, "r")
    f1 = f.readlines()
    f.close()
    P1_pos = []

    #identify positions of different sequances (P1) blocks
    for i in range(len(f1)):
        if ("P1;" in f1[i]):
            P1_pos.append(i)
    sec_1 = P1_pos[0]
    sec_2 = P1_pos[1]

    #remove empty lines and split into 2 blocks: seq and structure
    AA_struc = ''.join(
        [str(elem.rstrip("\n").rstrip("*")) for elem in f1[sec_1 + 2:sec_2]])
    AA_seq = ''.join(
        [str(elem.rstrip("\n").rstrip("*")) for elem in f1[sec_2 + 2:]])

    chain_break_seq = AA_seq.index('/')
    AA_struc_new = AA_struc[:chain_break_seq] + '/' + AA_struc[
        chain_break_seq + 1:]

    AA_struc_new = wrap(AA_struc_new, 75)  #split after 75 characters
    AA_seq_new = wrap(AA_seq, 75)

    AA_struc_new = '\n'.join([str(elem) for elem in AA_struc_new])
    AA_seq_new = '\n'.join([str(elem) for elem in AA_seq_new])

    struc_sec = f1[sec_1] + f1[sec_1 + 1] + AA_struc_new + "\n"
    seq_sec = f1[sec_2] + f1[sec_2 + 1] + AA_seq_new + "\n"
    f = open("multi_align.ali", 'w')
    f.writelines(struc_sec)
    f.writelines(seq_sec)
    f.close()
Exemplo n.º 22
0
def simple_model(alignment, instances,
                 output=None, optimize=False, verbose=False):

    contents = identify_pir(alignment)

    # We redirect STDOUT and STDERR to output files
    if output is None: output = contents['seq']
    warnings.warn('STDOUT & STDERR will be redirected to log files.')
    sys.stdout = open(output + '.log', 'w')
    sys.stderr = open(output + '.err', 'w')

    if verbose: log.verbose()  # Commands MODELLER to display all log output

    env = environ()  # Initializes the 'environment' for this modeling run

    env.io.hetatm = True  # Allow the presence of hetatoms

    a = automodel(env,  # Loading the environment
                  alnfile=alignment,         # Assigning the PIR alignment
                  knowns=contents['str'],    # Listing the known structures
                  sequence=contents['seq'],  # Identify the Query Sequence
                  assess_methods=(assess.DOPE,
                                  assess.GA341,
                                  assess.DOPEHR))  # Energy evaluation methods

    # Setting Starting and Ending Model number
    a.starting_model, a.ending_model = 1, instances

    if optimize:
        # Very thorough VTFM optimization:
        a.library_schedule   = autosched.slow
        a.max_var_iterations = 300

        # Thorough MD optimization:
        a.md_level = refine.slow

        # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
        a.repeat_optimization = 2
        a.max_molpdf          = 1e6

    a.initial_malign3d = True

    a.make()  # Create the Model

    sys.stdout = sys.__stdout__  # restore stdout back to normal
    sys.stderr = sys.__stderr__  # restore stdout back to normal
    warnings.warn('STDOUT & STDERR have been restored.')

    # We delete the error file if no error has occurred
    ERRsize = os.path.getsize(output + '.err')
    if int(ERRsize) is 0:
        os.remove(output + '.err')
Exemplo n.º 23
0
def model_single_opt(num_models):

    #log.verbose()
    #log.minimal()
    env = environ()

    # Give less weight to all soft-sphere restraints:
    env.schedule_scale = physical.values(default=1.0, soft_sphere=0.7)

    #Considering heteroatoms and waters molecules
    env.io.hetatm = env.io.water = True
    # Directories with input atom files:
    env.io.atom_files_directory = './:../atom_files'


    # Modelling 'sequence' with file.ali
    a = automodel(env, alnfile='target_sequence-receptor_template.ali',
                  knowns='receptor_template',
                  sequence='target_sequence',
                  assess_methods=(assess.DOPE, assess.GA341)
                  )
    # Generating 3 models
    a.starting_model = 1
    a.ending_model = int(num_models)

    # Very thorough Variable Target Function Method (VTFM) optimization:
    a.library_schedule = autosched.slow
    a.max_var_iterations = 300

    # Thorough MD optimization:
    a.md_level = refine.slow
     
    # Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
    a.repeat_optimization = 2
    a.max_molpdf = 1e6

    a.make()

    # Get a list of all successfully built models from a.outputs
    ok_models = [x for x in a.outputs if x['failure'] is None]

    # Rank the models by DOPE score
    key = 'DOPE score'
    #print(ok_models)
    ok_models.sort(key=lambda a: a[key])

    # Get top model
    m = ok_models[0]
    print("Top model: %s (DOPE score %.100f)" % (m['name'], m[key]))

    return m['name'], m[key]
Exemplo n.º 24
0
 def __generate_model(self, alignment_file, pdb_id, sequence):
     os.chdir(str(Path(__file__).parent.parent) + '/modeller')
     generated_model = automodel(self.__environment(),
                                 alnfile=alignment_file,
                                 knowns=pdb_id,
                                 sequence=sequence,
                                 assess_methods=assess.DOPE)
     # code of the target
     generated_model.starting_model = 1  # index of the first model
     generated_model.ending_model = 5  # index of the last model
     # (determines how many models to calculate)
     generated_model.make()  # do the actual homology modeling
     os.chdir(str(Path(__file__).parent.parent.parent))
     return generated_model
Exemplo n.º 25
0
def modelowanie(aln, input_arg):
    log.verbose()  # request verbose output
    env = environ()  # create a new MODELLER environment to build this model in

    env.io.atom_files_directory = ['.', '../atom_files']

    a = automodel(env,
                  alnfile=aln,  # alignment filename
                  knowns=input_arg[2],  # codes of the templates
                  sequence=input_arg[1])  # code of the target
    a.starting_model = 1  # index of the first model
    a.ending_model = 5  # index of the last model
    a.md_level = refine.slow
    a.final_malign3d = True
    # (determines how many models to calculate)
    a.make()  # do the actual comparative modeling
    def _automodel_run(self, alin_file, knowns):
        amdl = automodel(self.env,
                         alnfile=alin_file,
                         knowns=knowns,
                         sequence='target',
                         assess_methods=(assess.DOPE, assess.GA341))
        amdl.starting_model = 1
        amdl.ending_model = 1

        #amdl.loop.starting_model = 1
        #amdl.loop.ending_model = 1

        orig_dir = os.getcwd()
        os.chdir(self.tmpdir)
        amdl.make()
        os.chdir(orig_dir)

        return amdl.outputs[0]
Exemplo n.º 27
0
def fold(target_name: str, target_sequence: str, template_name: str, template_chain: chr) -> StringIO:
    align(target_name, target_sequence, template_name, template_chain)
    model = automodel(env,
                      alnfile=f'alignment_{target_name}_and_{template_name}.pir',
                      knowns=template_name,
                      sequence=target_name,
                      assess_methods=(assess.DOPE, assess.GA341))
    model.make()
    # Delete unnecessary files that that just made
    for filename in os.listdir():
        if re.search(f'^{target_name}.*', filename) and not re.search('.*\.pdb$', filename):
            os.remove(filename)
    # Find the file that we want to return
    for filename in os.listdir():
        if re.search(f'^{target_name}\..*\.pdb$', filename):
            folded_pdb_file = open(filename)
            break
    folded_pdb_file_text = folded_pdb_file.read()
    folded_pdb_file.close()
    return StringIO(folded_pdb_file_text)
Exemplo n.º 28
0
def complete_residues(pdbcode, align_file="protein.ali", loop_ref=False):
    """
    Function that completes residues based on an alignment file using MODELLER software.
    :param pdbcode: PDB code identifier of the structure with missing residues.
    :param align_file: Path to the align-formatted file with gaps as missing residues.
    :param loop_ref: (optional) Boolean for specifying loop refinement, doesn't always work.
    :return:
    """
    # Get the sequence of the coded PDB file, and write to an alignment file
    e = environ()
    m = model(e, file=pdbcode)
    aln = alignment(e)
    aln.append_model(m, align_codes=pdbcode)
    aln.write(file=pdbcode + ".seq")

    # Completing residues
    log.verbose()
    env = environ()

    # directories for input atom files (local dir)
    env.io.atom_files_directory = ["."]

    if loop_ref is True:
        # For loop refinement - Doesn't always work
        a = loopmodel(env,
                      alnfile=align_file,
                      knowns=pdbcode,
                      sequence=code + "_fill")
        a.loop.starting_model = 1
        a.loop.ending_model = 2
        a.loop.md_level = refine.fast
    else:
        a = automodel(env,
                      alnfile=align_file,
                      knowns=pdbcode,
                      sequence=pdbcode + "_fill")

    a.starting_model = 1
    a.ending_model = 1

    a.make()
Exemplo n.º 29
0
def main():
    input_file = args_.input_argument
    output_file = args_.output_argument
    sys.stdout = open(output_file[0], 'w')  # log file name
    env = environ()
    align_file = input_file[0]  # .ali file containing seq and pdb names
    all_info = align_file.split('/')[-1]
    seq = all_info.split('-')[0]  # query name
    pdb = all_info.split('-')[1].split('.')[0]  # pdb name
    a = automodel(
        env,
        alnfile=align_file,
        knowns=pdb,
        sequence=seq,
        assess_methods=(
            assess.DOPE,
            #soap_protein_od.Scorer(),
            assess.GA341))
    a.starting_model = 1
    a.ending_model = 5
    a.make()
Exemplo n.º 30
0
def model_del(path_to_sequence, path_to_template='./best_model_FLCN.pdb'):
    '''This function invokes sali modeller automodel,
    for a given sequence on a give template'''

    # set up an alignment, this is solely for converting the
    # fasta files to the sali pir format
    aln = alignment(env)
    aln.append(file=path_to_sequence, alignment_format='FASTA')
    aln.write(file=path_to_sequence + '.ali', alignment_format='PIR')
    # We will need the align code later, so let's put that here, this only works if
    path_fields = path_to_sequence.split('/')
    name_field = path_fields[-1]
    name_no_extension = name_field.split('.')[0]
    print(name_no_extension)

    # and now we can set up an alignment for the actual modelling
    aln = alignment(env)
    # read the template
    mdl = model(env,
                file=path_to_template)  #, model_segment=('FIRST:A', 'LAST:A'))
    # add the template to the alignment
    aln.append_model(mdl, align_codes='template')
    # and then we add the sequence with the deletion
    aln.append(file=path_to_sequence + '.ali',
               align_codes='ALL',
               alignment_format='PIR')
    # perform an alignment
    aln.align2d()
    # build the model, using the automodel class
    a = automodel(env,
                  alnfile=aln,
                  knowns='template',
                  sequence=name_no_extension,
                  assess_methods=[assess.normalized_dope, assess.DOPE])
    #index of the first model
    a.starting_model = 1
    #index of the last model
    a.ending_model = 25
    a.make()
    a.write(file='./models/' + name_no_extension + '.pdb', model_format='PDB')
Exemplo n.º 31
0
def get_restraints(pdbfname, outrsrname):
	'''get all restraints (stereochemical and homology derivied) from a PDB file'''
	# step 1. generate self alignment
	root = pdbfname.split('.pdb')[0]
	mdl = model(env, file = pdbfname)
	aln = alignment(env)
	aln.append_model(mdl, root, pdbfname)
	aln.append_model(mdl, root+'.target')
	aln.align()
	alnfname = unique_name()+'.self.aln'
	aln.write(alnfname)
	# step 2. build model using self alignment
	a = automodel(env, alnfile = alnfname, knowns = root, sequence = root+'.target')
	a.starting_model = 1
	a.ending_model   = 1
	a.make()
	# step 3. write out restraints from the automodel module
#	commands.getoutput('rm '+alnfname+' '+root+'.target.*')
	a.restraints.condense()
	a.restraints.write(outrsrname)

	commands.getoutput('rm '+alnfname)
	return a.restraints, root+'.target.B99990001.pdb'
def Build3DModels(PIRfile,
                  PDBDir,
                  seqName=None,
                  templateNames=None,
                  maxCaCaDist=30,
                  numModels=1):
    if seqName is None and templateNames is None:
        sName, tNames = ExtractNames(PIRfile)
    elif seqName is None:
        sName, _ = ExtractNames(PIRfile)
        tNames = templateNames
    elif templateNames is None:
        _, tNames = ExtractNames(PIRfile)
        sName = seqName
    else:
        sName, tNames = seqName, templateNames

    #log.verbose()    # request verbose output
    log.minimal()
    env = environ()  # create a new MODELLER environment to build this model in

    # directories for input atom files
    if isinstance(PDBDir, list):
        env.io.atom_files_directory = PDBDir
    else:
        env.io.atom_files_directory = [PDBDir]

    a = automodel(
        env,
        alnfile=PIRfile,  # alignment filename
        knowns=tuple(tNames),  # codes of the templates
        sequence=sName)  # code of the target

    a.max_ca_ca_distance = maxCaCaDist  # long distance restraints
    a.starting_model = 1  # index of the first model
    a.ending_model = numModels  # index of the last model
    a.make()  # do the actual homology modeling
Exemplo n.º 33
0
def modelSingle():
    for pPair in lTuProts:
        folder = pPair[0].split("-")[0] + "-" + pPair[1].split("-")[
            0] + "_" + pPair[0].split("-")[1] + "-" + pPair[1].split("-")[1]
        ppi = folder.split("_")[0]
        if os.path.isfile(dir + "/" + folder + "/" + ppi + '.ini'):
            pass
        else:
            os.chdir(dir + folder)
            os.system("cp ../%s ./" % (template))
            sys.stdout = open("model-single_" + ppi + ".log", 'w')
            env = environ()
            a = automodel(
                env,
                alnfile=ppi + "_" + template.split(".")[0] + '.ali',
                knowns=template.split(".")[0],
                sequence=ppi,
                assess_methods=(
                    assess.DOPE,
                    #soap_protein_od.Scorer(),
                    assess.GA341))
            a.starting_model = 1
            a.ending_model = 5
            a.make()
Exemplo n.º 34
0
def run_automodel(template_list, target_file, num_models: int = 5):
    """

    :param template_list: list of template codes
    :param target_file: the .ali of the target
    :param num_models: integer
    :return: best model

    """

    target_filepath = main_dir / target_file
    target_name = pl.Path(target_file).stem  # T1001-mult
    (target_code, extra) = target_name.split('-')  # T1001
    a = automodel(env,
                  alnfile=str(target_filepath),
                  knowns=template_list,
                  sequence=target_code,
                  assess_methods=(assess.DOPE, assess.GA341))
    a.starting_model = 1
    a.ending_model = int(num_models)
    a.make()

    # Get a list of all successfully built models from a.outputs
    ok_models = [x for x in a.outputs if x['failure'] is None]
    # Rank the models by DOPE score
    key = 'DOPE score'
    if sys.version_info[:2] == (2, 3):
        ok_models.sort(lambda a, b: cmp(a[key], b[key]))
    else:
        ok_models.sort(key=lambda a: a[key])

    # Get top model
    m = ok_models[0]

    print("Top model: %s (DOPE score %.3f)" % (m['name'], m[key]))
    return (m['name'])
parser.add_option("-c", dest="cid")
parser.add_option("-i", dest="ite")
parser.add_option("-r", dest="run")
(options, args) = parser.parse_args()

oali = options.mut + '-' + options.host + '.ali'
odope = 'dope' + options.run + '.seq' + options.ite

# Give less weight to all soft-sphere restraints:
env = environ()
env.schedule_scale = physical.values(default=1.0, soft_sphere=0.7)
env.io.atom_files_directory = ['.', '../atom_files']
env.io.hetatm = False

a = automodel(env, alnfile=oali,
              knowns=options.host, sequence=options.mut,
	      assess_methods=(assess.normalized_dope,assess.DOPEHR))
#	      assess_methods=(assess.DOPEHR))

a.starting_model = 1
a.ending_model = 1

# Very thorough VTFM optimization:
a.library_schedule = autosched.slow
a.max_var_iterations = 300

# Thorough MD optimization:
a.md_level = refine.slow

# Repeat the whole cycle 2 times and do not stop unless obj.func. > 1E6
#a.repeat_optimization = 2
Exemplo n.º 36
0
from modeller import *
from modeller.automodel import *

env = environ()
a = automodel(env, alnfile='TvLDH-1bdmA.ali',
              knowns='1bdmA', sequence='TvLDH',
              assess_methods=(assess.DOPE, assess.GA341))
a.starting_model = 1
a.ending_model = 5
a.make()
Exemplo n.º 37
0
a = MyModel(env,
              alnfile='all_align_final1.ali',
              #knowns=('3t97C', '3ghgA', '3ghgA', '3u0cA'),
              knowns=('4j73A'),  
              sequence='SEA4',
              assess_methods=(assess.DOPE, assess.GA341))
            
a.starting_model= 1                 # index of the first model
a.ending_model  = 20                # index of the last model
                                    # (determines how many models to calculate)
a.make()                            # do homology modeling

"""
a = automodel(env, 
              alnfile='all_align_final1.ali',
              knowns=('Vp133B', 'Vp133A'),
              #knowns=('4j73A'),  
              sequence='Vp133',
              assess_methods=(assess.DOPE, assess.GA341))

a.starting_model = 1
a.ending_model = 100

a.make()
#"""

for files in os.listdir('.'):
    if fnmatch.fnmatch(files, 'Vp133.B*.pdb'):
        print files
        mdl = model(env, file=files)
        mdl.rename_segments('A', 52)
        mdl.write(files)
Exemplo n.º 38
0
from modeller import * 
from modeller.automodel import * 
log.verbose()    # request verbose output
env = environ()  # create a new MODELLER environment to build this model in
env.io.atom_files_directory = './:../atom_files'
a = automodel(env,
              alnfile  = 'alignm_CTD.pir', # must have this alignment file 
              knowns   = ('d1c7ka_','PoingAA', ),
              sequence = 'query') #name of models
a.starting_model= 1
a.ending_model  = 50 # number of models made
a.make()
from modeller import *
from modeller.automodel import *

log.verbose()
env = environ()

# 1) directorio donde se encuentran los ficheros con coordenadas de moldes/templates,
# con extension .pdb,.atm,.ent
env.io.atom_files_directory = './template/'

# 2) prepara el modelado
a = automodel(env,
              alnfile  = './template/d1.ali',  # fichero con el alineamiento
              knowns   = '3TBG_A',              # nombre del template como aparece en alnfile
              sequence = 'd2j0da1 ',             # nombre de secuencia problema como aparece en alnfile
              assess_methods=(assess.DOPE))

a.starting_model= 1                           # define cuantos modelos diferentes quieres
a.ending_model  = 2

# 3) accion!
a.make()
Exemplo n.º 40
0
#!/usr/bin/python
# Comparative modeling with multiple templates
from modeller import *
from modeller.automodel import *    # Load the automodel class

log.verbose()    # request verbose output
env = environ()  # create a new MODELLER environment to build this model in

# directories for input atom files
env.io.atom_files_directory = ['.', '/home/hansaim/RhoGAP/templates/']

a = automodel(env,
              alnfile  = '/home/hansaim/RhoGAP/comp155_c0_seq1/align/comp155_c0_seq1_noSig.pir', # alignment filename
              knowns   = ('2ovj','3wpq'),     # codes of the templates
              sequence = 'comp155_c0_seq1')               # code of the target
a.starting_model= 1                 # index of the first model
a.ending_model  = 2                 # index of the last model
                                    # (determines how many models to calculate)
#aln = alignment(env)
#aln.append(file='clustalo-Lbtemp_pdbseq.pir', align_codes='all')
#aln.check()

#Very thorough VTFM optimization:
a.library_schedule = autosched.slow
a.max_var_iterations = 500

#thorough MD optimization:
a.md_level = refine.slow

#repeat the whole cycle 5 times and do not stop unless obj.func. > 1e6
a.repeat_optimization = 5
from modeller import *
from modeller.automodel import *

env = environ()
a = automodel(env, alnfile='example.ali',
              knowns='3eeh', sequence='T0527',
              assess_methods=(assess.DOPE, assess.GA341))
a.starting_model = 1
a.ending_model = 5
a.make()
         # Parameters
         # - gap_function makes the gaps in the MSA dependent on the structural
         #   context
         aln.salign(gap_function=True)
     
         # store the alignment
         aln.write(file=seqname+'-multiple_n_'+str(n_templates)+'.ali', alignment_format='PIR')
         
     
     # automodel reads the alignment file and actually does the homology modeling for us.
     # the output is a .pdb file, to be seen in a.outputs.
     # the parameter assess_methods is used to check the quality of the model
     # (see also Kryshtafovych and Fidelis, 2009)
     a = automodel(env,
                   alnfile = seqname+'-multiple_n_'+str(n_templates)+'.ali',
                   knowns = map(get_tplname, templates),
                   sequence = seqname,
                   assess_methods=[getattr(assess, am) for am in assessment_models])
     
     # index of the first/last model
     # (determines how many models to calculate)
     a.starting_model= 1
     a.ending_model = 3
     
     # do the actual homology modeling
     a.make()
 
     # check the assessment score
     for i in xrange(3):
         print 'Model', i+1
         for am in assessment_models:
Exemplo n.º 43
0
from modeller.automodel import *   

log.verbose()    
env = environ() 

# 1) directorio donde se encuentran los ficheros con coordenadas de moldes/templates, 
# con extension .pdb,.atm,.ent
env.io.atom_files_directory = 'C:/Users/Toshiba/Dropbox/LCG/4to semestre/Bioinfo/proyectos/Estrcutural/tarea 4/templates'

# 2) prepara el modelado
a = automodel(env,
              alnfile  = 'd1devc.ali',  # fichero con el alineamiento
              knowns   = 'd1dd.pdb',              # nombre del template como aparece en alnfile
              sequence = 'd2j.pdb',             # nombre de secuencia problema como aparece en alnfile
	          assess_methods=(assess.DOPE))      

a.starting_model= 1                           # define cuantos modelos diferentes quieres
a.ending_model  = 2                 
				  
# 3) accion! 
a.make()
Exemplo n.º 44
0
	mdl_arm = model(env)
	mdl_arm.read(file= known_mod)
	aln_final.append_model(mdl_arm, align_codes=known_mod, atom_files=known_mod)
	aln_final.salign(
		  gap_function=False,
		  feature_weights=(8., 0., 0., 0., 0., 0.),	# aligning the known region with the whole sequence
		  similarity_flag=True) 

		# use the newly made pdb file as a template for the whole sequence
	aln2 = alignment(env, file='alignments/BCAT.ali')
	mdl2 = model(env)
	mdl2.read(file='CTD', model_segment=('FIRST:@','END:@'))
	aln2.append_model(mdl2, align_codes='CTD')
	aln2.align()
	aln2.write(file='alignments/BCAT_CTD.ali')

		# append the CTD to the whole sequence alignment file
	aln_final.append(file='alignments/BCAT_CTD.ali', align_codes='CTD')
	aln_final.write(file='alignments/BCAT_main.ali')
	aln_final.write(file='alignments/BCAT_main.pap', alignment_format='PAP', alignment_features='INDICES CONSERVATION')
		# make pdb models for the arm region and connected CTD
	mdl_complete = automodel(env, alnfile  = 'alignments/BCAT_main.ali', knowns = (known_mod,'CTD'), sequence = 'BCAT', assess_methods=(assess.DOPE, assess.GA341, assess.normalized_dope))
	mdl_complete.starting_model = 1
 	mdl_complete.ending_model = 1 # if you increase number of models make sure you adjust the renaming convention below
	mdl_complete.make()
	x = x + 1
	os.rename('BCAT.B99990001.pdb', 'models/BCAT.B9999'+str(x)+'.pdb')	#will place models in a new folder with 
	os.rename('BCAT.V99990001', 'models/BCAT.V9999'+str(x)+'.pdb')		# their appropriate violation file
	os.rename('BCAT.D00000001', 'models/BCAT.D0000'+str(x)+'.pdb')		# and MD records

Exemplo n.º 45
0
from modeller.automodel import *   # Load the automodel class

log.verbose()                       # request verbose output
env = environ() # create a new MODELLER environment to build this model in

# directories for input atom files
env.io.atom_files_directory = './:./atom_files'

a = automodel(env,
              alnfile  = 'fdxCWW.pir', # alignment filename
              knowns   = ('1fxd', '1fdn'),  # codes of the templates
              sequence = 'ferodoxM')         # code of the target

#a.auto_align() # get an automatic alignment

a.make()       # do the actual homology modelling

from modeller import *
from modeller.automodel import *
from modeller.scripts import complete_pdb
import os
import IMP.em
import IMP.multifit

os.chdir('output')

env = environ()
env.io.atom_files_directory = ['../data/templates']
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')
a = automodel(env, alnfile='groel-1iokA.ali',
              knowns='1iok', sequence='P0A6F5',
              assess_methods=assess.DOPE)
a.starting_model = 1
a.ending_model = 10
a.make()

# Get a list of all successfully built models from a.outputs

ok_models = filter(lambda x: x['failure'] is None, a.outputs)

#truncated the models, as residues 524-548 were not covered by the template
truncated_models_fn=[]
full_model_norm_dope_scores=[]
for ok_model in ok_models:
    mdl_fn=ok_model['name']
    mdl = complete_pdb(env, mdl_fn)
from modeller import *
from modeller.automodel import *
#from modeller import soap_protein_od

env = environ()
a = automodel(env, alnfile='TvLDH-1bdmA.ali',
              knowns='1bdmA', sequence='TvLDH',
              assess_methods=(assess.DOPE,
                              #soap_protein_od.Scorer(),
                              assess.GA341))
a.starting_model = 1
a.ending_model = 5
a.make()
Exemplo n.º 48
0
# Comparative modeling by the automodel class
from modeller import *              # Load standard Modeller classes
from modeller.automodel import *    # Load the automodel class

log.verbose()    # request verbose output
env = environ()  # create a new MODELLER environment to build this model in

# directories for input atom files
env.io.atom_files_directory = ['../data/']

a = automodel(env,
              alnfile  = '../data/align-ligand.ali',     # alignment filename
              knowns   = '1j4hA',              # codes of the templates
              sequence = 'model')              # code of the target
a.starting_model= 1                 # index of the first model
a.ending_model  = 1                 # index of the last model
                                    # (determines how many models to calculate)

a.library_schedule = autosched.slow
a.max_var_iterations = 300
a.md_level = refine.slow
a.repeat_optimization = 3
a.max_molpdf = 1e6

a.make()                            # do the actual comparative modeling
    def modeller_fun(ALI_file, loop):
        """This is the function that does the modeling, it needs the argument loop to tell it to use loopmodel or automodel"""

        # Use 8 CPUs in a parallel job on this machine
        j = job(modeller_path="/home/software/science/modeller/bin/modslave.py")
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        j.append(local_slave())
        
        log.verbose()                                # request verbose output
        env = environ()                              # create a new MODELLER environment to build this model in
        
        # directories for input atom files
        env.io.atom_files_directory = '/home/mnellen/pamgene/modeled_NRs/'
        
        # Read in HETATM records from template PDBs
        env.io.hetatm = True
        
        # Loop Optimization
        # Use dope_loopmodel or dopehr_loopmodel in place of loopmodel to obtain better quality loops (but slower)
        if loop:
            a = loopmodel(env,
                      alnfile  = ALI_file,               # alignment filename
                      knowns   = ('subject',),           # codes of the templates
                      sequence = 'query')                # code of the target
        else:
           
            a = automodel(env,
                      alnfile  = ALI_file,               # alignment filename
                      knowns   = ('subject',),           # codes of the templates
                      sequence = 'query')                # code of the target

        a.starting_model= 1                              # index of the first model
        if loop:
            a.ending_model  = 10                             # index of the last model
        else:
            a.ending_model  = 100                            # index of the last model
       
        # Optimization
        # CG
        if loop:
            a.library_schedule = autosched.fast           # Very thorough VTFM optimization
        else:
            
            a.library_schedule = autosched.slow          # Very thorough VTFM optimization
        a.max_var_iterations = 300                    # Select length of optimizations
        a.max_molpdf = 1e6                            # do not stop unless obj.func. > 1E6
        
        # Loop Modelling
        if loop:
            a.loop.starting_model = 1           # First loop model
            a.loop.ending_model   = 10          # Last loop model
            a.loop.md_level       = refine.slow # Loop model refinement level
        
        #MD
        #a.md_level = refine.slow                      # model refinement level
        
        # Repeat the whole cycle 2 times 
        #a.repeat_optimization = 2
        
        a.use_parallel_job(j)                        # Use the job for model building
        a.make()                                     # do the actual homology modeling     
Exemplo n.º 50
0
    def makeModel(self, pdbFilename, sequenceFilename, outFile, projName=' ', chain=' ', captermini=False, allHydrogen=False):
        """Creates a PDB file for the sequence by fitting it to the PDB file using Modeller.

        myModel.make_model(pdbFile, sequenceFilename, outFile)
    
        REQUIRED ARGUMENTS
          pdbFilename - the filename of the PDB file to fit to
          sequenceFilename - the filename of the sequence to model, should contain one sequence using one letter code without spaces
          outFile - filename to write final structure to

        OPTIONAL ARGUMENTS
          projName - if not specified a temporary working directory is created and deleted once the model is completed.  If specified, all temporary files will be stored in the directory name specified.
          chain - the one-character chain ID of the chain to import (default ' ')

        RETURN VALUES
         None

        """
    
        # Ensure files exists.
        if not os.path.exists(pdbFilename):
            raise ParameterException, "Specified PDB file %s not found." % pdbFilename
        if not os.path.exists(sequenceFilename):
            raise ParameterException, "Specified sequence file %s not found." % sequenceFilename
    
        # Append full path to pdbfilename.
        pdbFilename = os.path.abspath(pdbFilename)

        # Create a directory for running MODELLER.
        delProj = False # whether to delete working directory at end
        if projName == ' ':
            projName = tempfile.mkdtemp()
            delProj = True
        else:
            if os.path.exists(projName):
                for filename in os.listdir(projName):
                    os.remove(os.path.join(projName,filename))
                os.rmdir(projName)
            os.mkdir(projName)
        projName = os.path.abspath(projName) # full path to working directory

        # Get the complete sequence.
        completeSequence = self.getCompleteSequenceSimple(pdbFilename, chain)
        nResidues = len(completeSequence)
        print "PDB sequence: " + completeSequence

        # read in the sequence
        seqFile = open(sequenceFilename, 'r')
        seq = seqFile.readline().strip()
        seqFile.close()
        print "target sequence: " + seq

        # Change working directory to temporary directory.
        oldDir = os.getcwd()
        os.chdir(projName)

        # create the PIR format sequence file for Modeller
        modSeqFn = 'target.ali'
        modSeqFile = open(modSeqFn, 'w')
        print >> modSeqFile, ">P1;target"
        print >> modSeqFile, "sequence:target:::::::0.00: 0.00"
        print >> modSeqFile, seq + "*"
        modSeqFile.close()
	

        if (allHydrogen):
	    class mymodel (allhmodel):
                if (captermini):
                    def special_patches(self, aln):
                        # Acylate the N-terminal
                        self.patch(residue_type='ACE ', residues=(self.residues[0]))
                        self.patch(residue_type='CT2 ', residues=(self.residues[-1]))

        elif (captermini):
	    class mymodel (automodel):
		def special_patches(self, aln):
		    # Acylate the N-terminal 
		    self.patch(residue_type='ACE ', residues=(self.residues[0])) 				
		    self.patch(residue_type='CT2 ', residues=(self.residues[-1])) 				
	

        # Create a new environemnt.
        env = environ()

        # Override automatic patching for NTER an CTER 
        if (captermini):
	        env.patch_default = False

        # do alignment
        aln = alignment(env)
        mdl = model(env, file=pdbFilename)
        aln.append_model(mdl, align_codes='template', atom_files=pdbFilename)
        aln.append(file='target.ali', align_codes='target')
        aln.align2d()
        aln.write(file='alignment.ali', alignment_format='PIR')
        aln.write(file='alignment.pap', alignment_format='PAP')

        # make a single model
        if (captermini | allHydrogen):
            a = mymodel(env, alnfile='alignment.ali', knowns='template', sequence='target')
        else:
            a = automodel(env, alnfile='alignment.ali', knowns='template', sequence='target')
        a.starting_model = 1
        a.ending_model = 1
        a.make()

        # go back to old directory
        os.chdir(oldDir)
   
        # copy to specified file (outfile) in next directory up
        shutil.copyfile(os.path.join(projName, "target.B99990001.pdb"), outFile)

        # remove working directory if just using temp dir
        if delProj:
          for filename in os.listdir(projName):
            os.remove(os.path.join(projName, filename))
          os.rmdir(projName)
Exemplo n.º 51
0
#!/usr/bin/python
# Comparative modeling with multiple templates
from modeller import *
from modeller.automodel import *    # Load the automodel class

log.verbose()    # request verbose output
env = environ()  # create a new MODELLER environment to build this model in

# directories for input atom files
env.io.atom_files_directory = ['.', '/home/hansaim/RhoGAP/comp155_c0_seq1']

a = automodel(env,
              alnfile  = 'clustalo-Lbtemp_pdbseq.pir', # alignment filename
              knowns   = ('1xa6', '1f7c'),     # codes of the templates
              sequence = 'comp155_c0_seq1')               # code of the target
a.starting_model= 1                 # index of the first model
a.ending_model  = 1                 # index of the last model
                                    # (determines how many models to calculate)
#aln = alignment(env)
#aln.append(file='clustalo-Lbtemp_pdbseq.pir', align_codes='all')
#aln.check()

a.make()                            # do the actual comparative modeling
Exemplo n.º 52
0
from modeller.automodel import *
log.verbose()
env = environ()

#env.io.atom_files_directory = 'pdb_files'
env.io.atom_files_directory = 'pdb2'

a = automodel( env, alnfile='build_profile.ali', knowns='3U1W', sequence='T0644')

a.starting_model=1
a.ending_model=1

a.make()
import os
import sys
from modeller import * 
from modeller.automodel import *
from modeller import soap_protein_od

try:
    tt = 'all'
    log.minimal()
    env = environ()
    a = automodel(env, alnfile=os.getcwd() + '\\template_dimer_align2d.ali',knowns='template_dimer_' + tt, sequence='query',assess_methods=None)
    a.starting_model = 1
    a.ending_model = 1
    a.make()
except:
    FILE = open('run_status',"w")
    FILE.write(str(sys.exc_info()[0]))
    FILE.close()
    print("Unexpected error:", sys.exc_info()[0])
Exemplo n.º 54
0
f.write("structure:"+aligncode_ab+":FIRST:"+'A'+":LAST:"+'A'+":::-1.00:-1.00\n")
f.write(str(aligna[1].seq)[:align_CDR1a_begin_pos] + str(cdr1a_template_seq) + str(aligna[1].seq)[align_CDR1a_end_pos:align_CDR2a_begin_pos] +  str(cdr2a_template_seq) + str(aligna[1].seq)[align_CDR2a_end_pos:align_HV4a_begin_pos] + str(hv4a_template_seq) + str(aligna[1].seq)[align_HV4a_end_pos:align_CDR3a_begin_pos] + str(cdr3a_template_seq) + str(aligna[1].seq)[align_CDR3a_end_pos:] + "/" + str(alignb[1].seq)[:align_CDR1b_begin_pos] + str(cdr1b_template_seq) + str(alignb[1].seq)[align_CDR1b_end_pos:align_CDR2b_begin_pos] +  str(cdr2b_template_seq) + str(alignb[1].seq)[align_CDR2b_end_pos:align_HV4b_begin_pos] + str(hv4b_template_seq) + str(alignb[1].seq)[align_HV4b_end_pos:align_CDR3b_begin_pos]+ str(cdr3b_template_seq) + str(alignb[1].seq)[align_CDR3b_end_pos:]+"*\n")

#f.write(str(aligna[1].seq)[:align_CDR1alpha_begin_pos] + str(aligna[1].seq)[align_CDR1alpha_begin_pos+2:align_CDR2alpha_begin_pos] + str(aligna[1].seq)[align_CDR2alpha_begin_pos:align_CDR3alpha_begin_pos] + str(aligna[1].seq)[align_CDR3alpha_begin_pos:] + "/" + str(alignb[1].seq)[:align_CDR1beta_begin_pos] + str(alignb[1].seq)[align_CDR1beta_begin_pos:align_CDR2beta_begin_pos] + str(alignb[1].seq)[align_CDR2beta_begin_pos:align_CDR3beta_begin_pos] + str(alignb[1].seq)[align_CDR3beta_begin_pos:] + "*\n")

f.close()

from modeller import *
from modeller.automodel import *
log.none()
env = environ()
env.io.atom_files_directory = ['.', '/TCRmodeller/templates/ab_structures' ]

a = automodel(env, 
              alnfile=tmpdir+ '/'+ 'needle_tcr.ali',
              knowns=(aligncode_ab),
              sequence='tcr',
              assess_methods=(assess.DOPE, assess.GA341)
              )
a.md_level = refine.very_fast
a.starting_model = 1
a.ending_model = 1


'''
class MyLoop(loopmodel):
    # This routine picks the residues to be refined by loop modeling
    def select_loop_atoms(self):
        # Two residue ranges (both will be refined simultaneously)
        return selection(self.residue_range('91:', '105:'))

Exemplo n.º 55
0
from modeller import *
from modeller.automodel import *

log.verbose()
env = environ()

env.io.atom_files_directory = ['.', '../atom_files']

a = automodel(env, alnfile = 'seqs.ali', knowns = 'vp1', sequence = 'GQ121419')
a.starting_model = 1
a.ending_model =1
a.library_scedule=autosched.slow
a.max_var_iterations = 300
a.md_level=refine.slow
a.max_molpdf = 1e6
a.make()
Exemplo n.º 56
0
import sys
import os
sys.path.append('/usr/lib/python2.5/dist-packages/modeller/')
from modeller import *
from modeller.automodel import *
if __name__ == '__main__':
	#sys.stdout = open(os.devnull,"w")
	#sys.stderr = open(os.devnull,"w")
	path = '../data/%s' %(sys.argv[4])
	if os.path.exists(path):
		os.chdir(path)
	else:
		 os.makedirs(path)
		 os.chdir(path)
		 

	env = environ()
	a = automodel(env, alnfile=sys.argv[1],
	              knowns=sys.argv[2], sequence=sys.argv[3],
	              assess_methods=(assess.DOPE, assess.GA341))
	a.starting_model = 1
	a.ending_model = 1
	a.make()
	os.chdir('/home/rackham/workspace/UniprotMODELLER/')
Exemplo n.º 57
0
from modeller import *              
from modeller.automodel import *    

log.verbose()    
env = environ()  

env.io.atom_files_directory = 'C:\Structure\dga'

a = automodel(env,
              alnfile  = 'dga.dgat.ali',     
              knowns   = 'dga',              
              sequence = 'dgat')              
a.starting_model= 1                 
a.ending_model  = 1                 
                                    
a.make()                            # homology modeling
Exemplo n.º 58
0
# read in file written by MODELLER.run_align_to_templates(); creates tuple, e.g (1durA, 2fdnB, ...)
template_ids = tuple(["".join(x.strip().split("\t")) for x in open(TEMPLATE_IDS_FILE).readlines()])

from modeller import *
from modeller.automodel import *    # Load the automodel class

log.verbose()
env = environ(rand_seed=-12312)

# directories for input atom files
env.io.atom_files_directory = ['./%s_TEMPLATE_PDBS' % TARGET_ID]

a = automodel(env,
              alnfile=ALIGNMENT,            # alignment filename
              knowns=template_ids,          # codes of the templates
              sequence=TARGET_ID,           # code of the target
              assess_methods=(assess.GA341,
                              assess.DOPE))

a.set_output_model_format('PDB')

# prepare for an extremely fast optimization
if VERY_FAST:
    a.very_fast()

# index of the first model
a.starting_model = 1
# index of the last model (i.e. the total number of models)
a.ending_model = NUM_MODELS
# has to >0 if more than 1 model
a.deviation = DEVIATION
Exemplo n.º 59
0
from modeller import *
from modeller.automodel import *

env = environ()
a = automodel(env, alnfile='TvLDH-mult.ali',
              knowns=('1bdmA','2mdhA','1b8pA'), sequence='TvLDH',
              assess_methods=(assess.DOPE, assess.GA341))
a.starting_model = 1
a.ending_model = 5
a.make()
Exemplo n.º 60
0
# Homology modeling by the automodel class
from modeller import *              # Load standard Modeller classes
from modeller.automodel import *    # Load the automodel class

log.verbose()    # request verbose output
env = environ()  # create a new MODELLER environment to build this model in
env.io.hetatm = True # Ligand is made true
env.io.water = True  # Water molecule made true

# directories for input atom files
#env.io.atom_files_directory = ['.', '../atom_files']

a = automodel(env,
              alnfile  = 'alignment.ali',     # alignment filename
              knowns   = 'template',          # codes of the templates	
              sequence = 'model')             # code of the target
a.starting_model= 1                 # index of the first model
a.ending_model  = 5                 # index of the last model
                                    # (determines how many models to calculate)
a.make()                            # do the actual homology modeling