  
      def save(self):
          """ Write the serialized alignments file """
          logger.debug("Saving alignments")
          try:
              logger.info("Writing alignments to: '%s'", self.file)
              with open(self.file, self.serializer.woptions) as align:
                  align.write(self.serializer.marshal(self.data))
              logger.debug("Saved alignments")
          except IOError as err:
              logger.error("'%s' not written: %s", self.file, err.strerror)
  
      def backup(self):
          """ Backup copy of old alignments """
          logger.debug("Backing up alignments")
          if not os.path.isfile(self.file):
 
</s> remove         try:
            logger.info("Reading alignments from: '%s'", self.file)
            with open(self.file, self.serializer.roptions) as align:
                data = self.serializer.unmarshal(align.read())
        except IOError as err:
            logger.error("'%s' not read: %s", self.file, err.strerror)
            exit(1)
 </s> add         logger.info("Reading alignments from: '%s'", self.file)
        data = self.serializer.load(self.file) </s> remove         self.file = "{}.{}".format(filename, self.serializer.ext)
 </s> add         self.file = "{}.{}".format(filename, self.serializer.file_extension) </s> remove         try:
            with open(self.file, self.serializer.roptions) as align:
                data = self.serializer.unmarshal(align.read())
        except IOError as err:
            logger.error("Error: '%s' not read: %s", self.file, err.strerror)
            exit(1)
 </s> add         data = self.serializer.load(self.file) </s> remove         try:
            with open(state_file, "rb") as inp:
                state = self.serializer.unmarshal(inp.read().decode("utf-8"))
                self.state = state
                logger.debug("Loaded state: %s", state)
        except IOError as err:
            logger.warning("Unable to load state file. Graphing disabled: %s", str(err))
 </s> add         self.state = self.serializer.load(state_file)
        logger.debug("Loaded state: %s", self.state) </s> remove         with open(self.args.log_file_path, 'w') as lfile:
            lfile.write(self.serializer.marshal(changes))
 </s> add         self.serializer.save(self.args.log_file_path, changes)
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
  
      def save(self):
          """ Write the serialized alignments file """
          logger.debug("Saving alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
        logger.info("Writing alignments to: '%s'", self.file)
        self.serializer.save(self.file, self.data)
        logger.debug("Saved alignments")
  
      def backup(self):
          """ Backup copy of old alignments """
          logger.debug("Backing up alignments")
          if not os.path.isfile(self.file):
keep keep keep keep replace replace replace replace replace replace replace keep keep keep keep keep
 Standardize serialization (#903)

* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation 
lib/alignments.py