This opens a file and returns a handle object, which can be used for methods that need an open file, such as alignment.read_one(). Many methods (such as model.write()) can also be given a writeable file handle, to have them append their output to that file rather than creating a new one. (They can also be given a Python filelike object, such as sys.stdout or io.StringIO, to write to a Python file; however, this is less efficient as it must call Python functions to do the IO.) Similarly, many methods (such as model.read() can be given a readable file handle, or a Python filelike object.
The file is closed automatically when the handle object is deleted, or explicitly by calling its close method.
The mode argument functions similarly to that used by C or Python; i.e., the following modes are acceptable: 'r', 'w', 'rb' and 'wb', to open a file for reading in text mode, writing in text mode, reading in binary mode, or writing in binary mode, respectively. Note that while only Windows operating systems make a distinction between text and binary mode, MODELLER will do some additional checks on text format files to catch common mistakes (e.g., trying to read a Unicode rather than plain text file) so you should use the 'b' suffix on all platforms if you are using binary files.Example: See alignment.read_one() command.