예제 #1
0
    def load_data_J(self, filename, verbose=False):
        """Load in the experimental Jcoupling constant restraints from a .Jcoupling file format."""


        # Read in the lines of the biceps data file
        b = RestraintFile_J(filename=filename)
        data = []
        for line in b.lines:
                data.append( b.parse_line_J(line) )  # [restraint_index, atom_index1, res1, atom_name1, atom_index2, res2, atom_name2, atom_index3, res3, atom_name3, atom_index4, res4, atom_name4, J_coupling(Hz)]

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

        ### Jcoupling ###

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


        # add the Jcoupling restraints
        for entry in data:
            restraint_index, i, j, k, l, exp_Jcoupling, karplus  = entry[0], entry[1], entry[4], entry[7], entry[10], entry[13], entry[14]
            self.add_dihedral_restraint(i, j, k, l, exp_Jcoupling, model_Jcoupling=None, equivalency_index=None, karplus_key=karplus)

        # build groups of equivalency group indices, ambiguous group etc.
        self.build_groups_J()
예제 #2
0
    def load_expdata_J(self, filename, verbose=False):
        """Load in the experimental Jcoupling constant restraints from a .Jcoupling file format."""


        # Read in the lines of the biceps data file
        b = RestraintFile_J(filename=filename) 
	data = []
        for line in b.lines:
		data.append( b.parse_line_J(line) )  # [restraint_index, atom_index1, res1, atom_name1, atom_index2, res2, atom_name2, atom_index3, res3, atom_name3, atom_index4, res4, atom_name4, J_coupling(Hz)]
         
        if verbose:
            print 'Loaded from', filename, ':'
            for entry in data:
                print entry

        ### Jcoupling ###

        # the equivalency indices for Jcoupling are in the first column of the *.Jcoupling file
        equivalency_indices = [entry[0] for entry in data]
        if verbose:
            print 'distance 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 Jcoupling restraints
        for entry in data:
            restraint_index, i, j, k, l, exp_Jcoupling, karplus  = entry[0], entry[1], entry[4], entry[7], entry[10], entry[13], entry[14]
            self.add_dihedral_restraint(i, j, k, l, exp_Jcoupling, model_Jcoupling=None, equivalency_index=None, karplus_key=karplus)

        # build groups of equivalency group indices, ambiguous group etc.
        self.build_groups()
    sys.exit(1)


pdbfile = 'albo_37.pdb' 

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

Karplusfilename = 'Karplus.txt'
filename=Karplusfilename
with open(filename) as f:
        lines=f.readlines()
line=''.join(lines)
karplus = line.strip().split('\n')

r = RestraintFile_J()

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, a2, a3, a4 = int(Ind[i,0]), int(Ind[i,1]), int(Ind[i,2]), int(Ind[i,3])
    restraint_index = restraint_data[i,0]
    J_coupling      = restraint_data[i,1]
    r.add_line_J(restraint_index, a1, a2, a3, a4, topology, J_coupling, karplus)

print r

r.write('albo.Jcoupling')