Author: bugman Date: Sun Nov 4 14:56:03 2007 New Revision: 3408 URL: http://svn.gna.org/viewcvs/relax?rev=3408&view=rev Log: Removed junk code, left over from the copy from 'generic_fns/sequence.py'. Modified: 1.3/generic_fns/residue.py Modified: 1.3/generic_fns/residue.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/residue.py?rev=3408&r1=3407&r2=3408&view=diff ============================================================================== --- 1.3/generic_fns/residue.py (original) +++ 1.3/generic_fns/residue.py Sun Nov 4 14:56:03 2007 @@ -262,167 +262,3 @@ # Rename the residue is there is a match. if mol.res[i].num in residues or mol.res[i].name in residues: mol.res[i].num = new_number - - -class Residue: - def __init__(self, relax): - """Class containing functions specific to amino-acid sequence.""" - - self.relax = relax - - - def data_names(self): - """Function for returning a list of names of data structures associated with the sequence.""" - - return [ 'res' ] - - - - def load_PDB_sequence(self, run=None): - """Function for loading the sequence out of a PDB file. - - This needs to be modified to handle multiple peptide chains. - """ - - # Print out. - print "\nLoading the sequence from the PDB file.\n" - - # Reassign the sequence of the first structure. - if relax_data_store.pdb[run].structures[0].peptide_chains: - res = relax_data_store.pdb[run].structures[0].peptide_chains[0].residues - molecule = 'protein' - elif relax_data_store.pdb[run].structures[0].nucleotide_chains: - res = relax_data_store.pdb[run].structures[0].nucleotide_chains[0].residues - molecule = 'nucleic acid' - else: - raise RelaxNoPdbChainError - - # Add the run to 'relax_data_store.res'. - relax_data_store.res.add_list(run) - - # Loop over the sequence. - for i in xrange(len(res)): - # Append a data container. - relax_data_store.res[run].add_item() - - # Residue number. - relax_data_store.res[run][i].num = res[i].number - - # Residue name. - if molecule == 'nucleic acid': - relax_data_store.res[run][i].name = res[i].name[-1] - else: - relax_data_store.res[run][i].name = res[i].name - - # Select the residue. - relax_data_store.res[run][i].select = 1 - - - def read(self, run=None, file=None, dir=None, num_col=0, name_col=1, sep=None): - """Function for reading sequence data.""" - - # Test if the run exists. - if not run in relax_data_store.run_names: - raise RelaxNoPipeError, run - - # Test if the sequence data has already been read. - if relax_data_store.res.has_key(run): - raise RelaxSequenceError, run - - # Extract the data from the file. - file_data = self.relax.IO.extract_data(file, dir) - - # Count the number of header lines. - header_lines = 0 - for i in xrange(len(file_data)): - try: - int(file_data[i][num_col]) - except: - header_lines = header_lines + 1 - else: - break - - # Remove the header. - file_data = file_data[header_lines:] - - # Strip data. - file_data = self.relax.IO.strip(file_data) - - # Do nothing if the file does not exist. - if not file_data: - raise RelaxFileEmptyError - - # Test if the sequence data is valid. - for i in xrange(len(file_data)): - try: - int(file_data[i][num_col]) - except ValueError: - raise RelaxError, "Sequence data is invalid." - - # Add the run to 'relax_data_store.res'. - relax_data_store.res.add_list(run) - - # Fill the array 'relax_data_store.res[run]' with data containers and place sequence data into the array. - for i in xrange(len(file_data)): - # Append a data container. - relax_data_store.res[run].add_item() - - # Insert the data. - relax_data_store.res[run][i].num = int(file_data[i][num_col]) - relax_data_store.res[run][i].name = file_data[i][name_col] - relax_data_store.res[run][i].select = 1 - - - def sort(self, run=None): - """Function for sorting the sequence by residue number.""" - - # Test if the run exists. - if not run in relax_data_store.run_names: - raise RelaxNoPipeError, run - - # Test if the sequence data is loaded. - if not relax_data_store.res.has_key(run): - raise RelaxNoSequenceError, run - - # Sort the sequence. - relax_data_store.res[run].sort(self.sort_cmpfunc) - - - def sort_cmpfunc(self, x, y): - """Sequence comparison function given to the ListType function 'sort'.""" - - if x.num > y.num: - return 1 - elif x.num < y.num: - return -1 - elif x.num == y.num: - return 0 - - - def write(self, run=None, file=None, dir=None, force=0): - """Function for writing sequence data.""" - - # Test if the run exists. - if not run in relax_data_store.run_names: - raise RelaxNoPipeError, run - - # Test if the sequence data is loaded. - if not relax_data_store.res.has_key(run): - raise RelaxNoSequenceError, run - - # Open the file for writing. - seq_file = self.relax.IO.open_write_file(file, dir, force) - - # Loop over the sequence. - for i in xrange(len(relax_data_store.res[run])): - # Residue number. - seq_file.write("%-5i" % relax_data_store.res[run][i].num) - - # Residue name. - seq_file.write("%-6s" % relax_data_store.res[run][i].name) - - # New line. - seq_file.write("\n") - - # Close the results file. - seq_file.close()