Package generic_fns :: Module sequence
[hide private]
[frames] | no frames]

Module sequence

source code

Module for handling the molecule, residue, and spin sequence.

Functions [hide private]
 
copy(pipe_from=None, pipe_to=None, preserve_select=False, verbose=True)
Copy the molecule, residue, and spin sequence data from one data pipe to another.
source code
int
compare_sequence(pipe1=None, pipe2=None, fail=True)
Compare the sequence in two data pipes.
source code
 
display(sep=None, mol_name_flag=False, res_num_flag=False, res_name_flag=False, spin_num_flag=False, spin_name_flag=False)
Display the molecule, residue, and/or spin sequence data.
source code
 
generate(mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, pipe=None, select=True, verbose=True)
Generate the sequence item-by-item by adding a single molecule/residue/spin container as necessary.
source code
 
read(file=None, dir=None, file_data=None, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, spin_id=None)
Read the molecule, residue, and/or spin sequence data from file.
source code
 
validate_sequence(data, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, data_col=None, error_col=None)
Test if the sequence data is valid.
source code
 
write(file, dir=None, sep=None, mol_name_flag=False, res_num_flag=False, res_name_flag=False, spin_num_flag=False, spin_name_flag=False, force=False)
Write the molecule, residue, and/or sequence data.
source code
Variables [hide private]
  __package__ = 'generic_fns'

Imports: IntType, NoneType, count_molecules, count_residues, count_spins, exists_mol_res_spin_data, generate_spin_id, return_molecule, return_residue, return_spin, spin_id_to_data_list, spin_loop, pipes, RelaxError, RelaxDiffMolNumError, RelaxDiffResNumError, RelaxDiffSeqError, RelaxDiffSpinNumError, RelaxFileEmptyError, RelaxInvalidSeqError, RelaxNoSequenceError, RelaxSequenceError, open_write_file, read_spin_data, write_spin_data, sys


Function Details [hide private]

copy(pipe_from=None, pipe_to=None, preserve_select=False, verbose=True)

source code 

Copy the molecule, residue, and spin sequence data from one data pipe to another.

Parameters:
  • pipe_from (str) - The data pipe to copy the sequence data from. This defaults to the current data pipe.
  • pipe_to (str) - The data pipe to copy the sequence data to. This defaults to the current data pipe.
  • preserve_select (bool) - A flag which if True will cause spin selections to be preserved.
  • verbose (bool) - A flag which if True will cause info about each spin to be printed out as the sequence is generated.

compare_sequence(pipe1=None, pipe2=None, fail=True)

source code 

Compare the sequence in two data pipes.

Parameters:
  • pipe1 (str) - The name of the first data pipe.
  • pipe2 (str) - The name of the second data pipe.
  • fail (bool) - A flag which if True causes a RelaxError to be raised.
Returns: int
1 if the sequence is the same, 0 if different.
Raises:
  • RelaxError - If the sequence is different and the fail flag is True.

display(sep=None, mol_name_flag=False, res_num_flag=False, res_name_flag=False, spin_num_flag=False, spin_name_flag=False)

source code 

Display the molecule, residue, and/or spin sequence data.

This calls the write() function to do most of the work.

Parameters:
  • sep (str or None) - The column seperator which, if None, defaults to whitespace.
  • mol_name_flag (bool) - A flag which if True will cause the molecule name column to be written.
  • res_num_flag (bool) - A flag which if True will cause the residue number column to be written.
  • res_name_flag (bool) - A flag which if True will cause the residue name column to be written.
  • spin_name_flag (bool) - A flag which if True will cause the spin name column to be written.
  • spin_num_flag (bool) - A flag which if True will cause the spin number column to be written.
  • mol_name_flag (bool) - The column to contain the molecule name information.

generate(mol_name=None, res_num=None, res_name=None, spin_num=None, spin_name=None, pipe=None, select=True, verbose=True)

source code 

Generate the sequence item-by-item by adding a single molecule/residue/spin container as necessary.

Parameters:
  • mol_name (str or None) - The molecule name.
  • res_num (int or None) - The residue number.
  • res_name (str or None) - The residue name.
  • spin_num (int or None) - The spin number.
  • spin_name (str or None) - The spin name.
  • pipe (str) - The data pipe in which to generate the sequence. This defaults to the current data pipe.
  • select (bool) - The spin selection flag.
  • verbose (bool) - A flag which if True will cause info about each spin to be printed out as the sequence is generated.

read(file=None, dir=None, file_data=None, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, spin_id=None)

source code 

Read the molecule, residue, and/or spin sequence data from file.

Parameters:
  • file (str) - The name of the file to open.
  • dir (str or None) - The directory containing the file (defaults to the current directory if None).
  • file_data (list of lists) - An alternative to opening a file, if the data already exists in the correct format. The format is a list of lists where the first index corresponds to the row and the second the column.
  • spin_id_col (int or None) - The column containing the spin ID strings. If supplied, the mol_name_col, res_name_col, res_num_col, spin_name_col, and spin_num_col arguments must be none.
  • mol_name_col (int or None) - The column containing the molecule name information. If supplied, spin_id_col must be None.
  • res_name_col (int or None) - The column containing the residue name information. If supplied, spin_id_col must be None.
  • res_num_col (int or None) - The column containing the residue number information. If supplied, spin_id_col must be None.
  • spin_name_col (int or None) - The column containing the spin name information. If supplied, spin_id_col must be None.
  • spin_num_col (int or None) - The column containing the spin number information. If supplied, spin_id_col must be None.
  • sep (str or None) - The column separator which, if None, defaults to whitespace.
  • spin_id (None or str) - The spin ID string used to restrict data loading to a subset of all spins.

validate_sequence(data, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, data_col=None, error_col=None)

source code 

Test if the sequence data is valid.

The only function this performs is to raise a RelaxError if the data is invalid.

Parameters:
  • data (list of lists.) - The sequence data.
  • spin_id_col (int or None) - The column containing the spin ID strings.
  • mol_name_col (int or None) - The column containing the molecule name information.
  • res_name_col (int or None) - The column containing the residue name information.
  • res_num_col (int or None) - The column containing the residue number information.
  • spin_name_col (int or None) - The column containing the spin name information.
  • spin_num_col (int or None) - The column containing the spin number information.

write(file, dir=None, sep=None, mol_name_flag=False, res_num_flag=False, res_name_flag=False, spin_num_flag=False, spin_name_flag=False, force=False)

source code 

Write the molecule, residue, and/or sequence data.

This calls the relax_io.write_spin_data() function to do most of the work.

Parameters:
  • file (str) - The name of the file to write the data to.
  • dir (str or None) - The directory to contain the file (defaults to the current directory if None).
  • sep (str or None) - The column seperator which, if None, defaults to whitespace.
  • mol_name_flag (bool) - A flag which if True will cause the molecule name column to be written.
  • res_num_flag (bool) - A flag which if True will cause the residue number column to be written.
  • res_name_flag (bool) - A flag which if True will cause the residue name column to be written.
  • spin_name_flag (bool) - A flag which if True will cause the spin name column to be written.
  • spin_num_flag - A flag which if True will cause the spin number column to be written.
  • force (bin) - A flag which if True will cause an existing file to be overwritten.