code: def createFinalTPEDandTFAM(tped, toReadPrefix, prefix, snpToRemove):
      
      # First, copying the tfam
      try:
          shutil.copy(toReadPrefix + ".tfam", prefix + ".final.tfam")
      except IOError:
          msg = "%(toReadPrefix)s.tfam: can't copy file to " \
                "%(prefix)s.final.tfam" % locals()
          raise ProgramError(msg)
  
      # Next, copy the tped, and append at the end
      try:
          shutil.copy(toReadPrefix + ".tped", prefix + ".final.tped")
      except IOError:
          msg = "%(toReadPrefix)s.tped: can't copy fil to " \
                "%(prefix)s.final.tped" % locals()
          raise ProgramError(msg)
      tpedFile = None
      try:
          tpedFile = open(prefix + ".final.tped", "a")
      except IOError:
          msg = "%(prefix)s.final.tped: can't append to file" % locals()
          raise ProgramError(msg)
      for i, row in enumerate(tped):
          if i not in snpToRemove:
              print >>tpedFile, "\t".join(row)
      tpedFile.close()
docs: Creates the final TPED and TFAM.
  
      :param tped: a representation of the ``tped`` of duplicated markers.
      :param toReadPrefix: the prefix of the unique files.
      :param prefix: the prefix of the output files.
      :param snpToRemove: the markers to remove.
  
      :type tped: numpy.array
      :type toReadPrefix: str
      :type prefix: str
      :type snpToRemove: set
  
      Starts by copying the unique markers' ``tfam`` file to
      ``prefix.final.tfam``. Then, it copies the unique markers' ``tped`` file,
      in which the chosen markers will be appended.
  
      The final data set will include the unique markers, the chosen markers
      which were completed, and the problematic duplicated markers (for further
      analysis). The markers that were used to complete the chosen ones are not
      present in the final data set.