Example #1
0
    def load_data_cs_Ca(self, filename, verbose=False):
        """Load in the experimental chemical shift restraints from a .chemicalshift file format.
        """

        # Read in the lines of the chemicalshift data file
        b = RestraintFile_cs(filename=filename)
        if verbose:
                print b.lines
        data = []
        for line in b.lines:
                data.append( b.parse_line_cs(line) )  # [restraint_index, atom_index1, res1, atom_name1, chemicalshift]

        if verbose:
            print 'Loaded from', filename, ':'
            for entry in data:
                print entry

        ### distances ###

        # the equivalency indices for distances are in the first column of the *.biceps f
#       equivalency_indices = [entry[0] for entry in data]

        # add the chemical shift restraints
        for entry in data:
            restraint_index, i, exp_chemicalshift_Ca, model_chemicalshift_Ca  = entry[0], entry[1], entry[4], entry[5]
            self.add_chemicalshift_Ca_restraint(i, exp_chemicalshift_Ca, model_chemicalshift_Ca)

        # build groups of equivalency group indices, ambiguous group etc.

        self.compute_sse_chemicalshift_Ca()
Example #2
0
    def load_expdata_cs(self, filename, verbose=False):
        """Load in the experimental chemical shift restraints from a .chemicalshift file format.
	"""

        # Read in the lines of the chemicalshift data file
        b = RestraintFile_cs(filename=filename)
        if verbose:
		print b.lines
	data = []
        for line in b.lines:
                data.append( b.parse_line_cs(line) )  # [restraint_index, atom_index1, res1, atom_name1, chemicalshift]

        if verbose:
            print 'Loaded from', filename, ':'
            for entry in data:
                print entry

        ### distances ###

        # the equivalency indices for distances are in the first column of the *.biceps file
        equivalency_indices = [entry[0] for entry in data]
        if verbose:
            print 'chemicalshift equivalency_indices', equivalency_indices

        # compile ambiguity indices for distances
        """ ### not yet supported ###
        
          for pair in data['NOE_Ambiguous']:
            # NOTE a pair of multiple distance pairs
            list1, list2 = pair[0], pair[1]
            # find the indices of the distances pairs that are ambiguous
            pair_indices1 = [ data['NOE_PairIndex'].index(p) for p in list1]
            pair_indices2 = [ data['NOE_PairIndex'].index(p) for p in list2]
            self.ambiguous_groups.append( [pair_indices1, pair_indices2] )
          if verbose:
            print 'distance ambiguous_groups', self.ambiguous_groups
        except:
            print 'Problem reading distance ambiguous_groups.  Setting to default: no ambiguous groups.'
        """

        # add the chemical shift restraints
        for entry in data:
            restraint_index, i, exp_chemicalshift = entry[0], entry[1], entry[4]
            self.add_chemicalshift_restraint(i, exp_chemicalshift, model_chemicalshift=None, equivalency_index=restraint_index)

        # build groups of equivalency group indices, ambiguous group etc.
        self.build_groups()
pdbfile = '8690.pdb' 

# load in the pdbfile template 
topology = md.load_pdb(pdbfile).topology


#r = RestraintFile_cs()


#all_atom_indices = [atom.index for atom in topology.atoms]
#all_atom_residues = [atom.residue for atom in topology.atoms]
#all_atom_names = [atom.name for atom in topology.atoms]

for j in range(50):
	model_data=np.loadtxt('H/cs_%d.txt'%j)
	r = RestraintFile_cs()

	all_atom_indices = [atom.index for atom in topology.atoms]
	all_atom_residues = [atom.residue for atom in topology.atoms]
	all_atom_names = [atom.name for atom in topology.atoms]
	for i in range(Ind.shape[0]):
    		a1 = int(Ind[i])
    		restraint_index = restraint_data[i,0]
    		exp_chemical_shift        = restraint_data[i,1]
    		model_chemical_shift      = model_data[i]
    		r.add_line_cs(restraint_index, a1, topology, exp_chemical_shift, model_chemical_shift)

#print r

	r.write('cs_H/ligand1_%d.cs_H'%j)