code: def to_ped(self, outfile=None):
          ped_header = [
              '
              'IndividualID',
              'PaternalID',
              'MaternalID', 
              'Sex',
              'Phenotype',
          ]
          extra_headers = [
              'InheritanceModel',
              'Proband',
              'Consultand',
              'Alive'
          ]
          for individual_id in self.individuals:
              individual = self.individuals[individual_id]
              for info in individual.extra_info:
                  if info in extra_headers:
                      if info not in ped_header:
                          ped_header.append(info)
          self.logger.debug("Ped headers found: {0}".format(
              ', '.join(ped_header)
          ))
          if outfile:
              outfile.write('\t'.join(ped_header)+'\n')
          else:
              print('\t'.join(ped_header))
          for individual in self.to_json():
              ped_info = []
              ped_info.append(individual['family_id'])
              ped_info.append(individual['id'])
              ped_info.append(individual['father'])
              ped_info.append(individual['mother'])
              ped_info.append(individual['sex'])
              ped_info.append(individual['phenotype'])
              if len(ped_header) > 6:
                  for header in ped_header[6:]:
                      ped_info.append(individual['extra_info'].get(header, '.'))
              if outfile:
                  outfile.write('\t'.join(ped_info)+'\n')
              else:
                  print('\t'.join(ped_info))