Back to index

python-biopython  1.60
Public Member Functions | Public Attributes | Private Attributes
Bio.Phylo.PAML.yn00.Yn00 Class Reference
Inheritance diagram for Bio.Phylo.PAML.yn00.Yn00:
Inheritance graph
[legend]
Collaboration diagram for Bio.Phylo.PAML.yn00.Yn00:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def write_ctl_file
def read_ctl_file
def run

Public Attributes

 ctl_file
 alignment
 out_file

Private Attributes

 _options

Detailed Description

This class implements an interface to yn00, part of the PAML package.

Definition at line 17 of file yn00.py.


Constructor & Destructor Documentation

def Bio.Phylo.PAML.yn00.Yn00.__init__ (   self,
  alignment = None,
  working_dir = None,
  out_file = None 
)
Initialize the Yn00 instance. 

The user may optionally pass in strings specifying the locations
of the input alignment, the working directory and
the final output file. 

Definition at line 21 of file yn00.py.

00021 
00022                 out_file = None):
00023         """Initialize the Yn00 instance. 
00024         
00025         The user may optionally pass in strings specifying the locations
00026         of the input alignment, the working directory and
00027         the final output file. 
00028         """
00029         Paml.__init__(self, alignment, working_dir, out_file)
00030         self.ctl_file = "yn00.ctl"
00031         self._options = {"verbose": None,
00032                         "icode": None,
00033                         "weighting": None,
00034                         "commonf3x4": None,
00035                         "ndata": None}


Member Function Documentation

def Bio.Phylo.PAML.yn00.Yn00.read_ctl_file (   self,
  ctl_file 
)
Parse a control file and load the options into the yn00 instance.

Definition at line 57 of file yn00.py.

00057 
00058     def read_ctl_file(self, ctl_file):
00059         """Parse a control file and load the options into the yn00 instance.
00060         """
00061         temp_options = {}
00062         if not os.path.isfile(ctl_file):
00063             raise IOError("File not found: %r" % ctl_file)
00064         else:
00065             ctl_handle = open(ctl_file)
00066             for line in ctl_handle:
00067                 line = line.strip()
00068                 uncommented = line.split("*",1)[0]
00069                 if uncommented != "":
00070                     if "=" not in uncommented:
00071                         ctl_handle.close()
00072                         raise AttributeError, \
00073                             "Malformed line in control file:\n%r" % line
00074                     (option, value) = uncommented.split("=")
00075                     option = option.strip()
00076                     value = value.strip()
00077                     if option == "seqfile":
00078                         self.alignment = value
00079                     elif option == "outfile":
00080                         self.out_file = value
00081                     elif option not in self._options:
00082                         ctl_handle.close()
00083                         raise KeyError, "Invalid option: %s" % option
00084                     else:
00085                         if "." in value or "e-" in value:
00086                             try:
00087                                 converted_value = float(value)
00088                             except:
00089                                 converted_value = value
00090                         else:
00091                             try:
00092                                 converted_value = int(value)
00093                             except:
00094                                 converted_value = value
00095                         temp_options[option] = converted_value
00096             ctl_handle.close()
00097         for option in self._options.keys():
00098             if option in temp_options.keys():
00099                 self._options[option] = temp_options[option]
00100             else:
00101                 self._options[option] = None
                

Here is the call graph for this function:

def Bio.Phylo.PAML.yn00.Yn00.run (   self,
  ctl_file = None,
  verbose = False,
  command = "yn00",
  parse = True 
)

Definition at line 103 of file yn00.py.

00103 
00104                 parse = True):
00105         Paml.run(self, ctl_file, verbose, command)
00106         if parse:
00107             results = read(self.out_file)
00108         else:
00109             results = None
00110         return results

Here is the call graph for this function:

Dynamically build a yn00 control file from the options.

The control file is written to the location specified by the 
ctl_file property of the yn00 class.

Definition at line 36 of file yn00.py.

00036 
00037     def write_ctl_file(self):
00038         """Dynamically build a yn00 control file from the options.
00039         
00040         The control file is written to the location specified by the 
00041         ctl_file property of the yn00 class.
00042         """
00043         # Make sure all paths are relative to the working directory
00044         self._set_rel_paths()
00045         if True: #Dummy statement to preserve indentation for diff
00046             ctl_handle = open(self.ctl_file, 'w')
00047             ctl_handle.write("seqfile = %s\n" % self._rel_alignment)
00048             ctl_handle.write("outfile = %s\n" % self._rel_out_file)
00049             for option in self._options.items():
00050                 if option[1] is None:
00051                     # If an option has a value of None, there's no need
00052                     # to write it in the control file; it's normally just
00053                     # commented out.
00054                     continue
00055                 ctl_handle.write("%s = %s\n" % (option[0], option[1]))
00056             ctl_handle.close()

Here is the call graph for this function:


Member Data Documentation

Definition at line 30 of file yn00.py.

Definition at line 77 of file yn00.py.

Definition at line 29 of file yn00.py.

Definition at line 79 of file yn00.py.


The documentation for this class was generated from the following file: