import sys

class Genotype(object):
    def __init__(self, variant, sample_name, gt):
        self.format = dict()
        self.variant = variant
        self.set_format('GT', gt)

    def set_format(self, field, value):
        if field in [i.id for i in self.variant.format_list]:
            self.format[field] = value
            if field not in self.variant.active_formats:
                self.variant.active_formats.add(field)
        else:
            # FIXME This should be an exception
            sys.stderr.write('\nError: invalid FORMAT field, \"' + field + '\"\n')
            exit(1)

    def get_format(self, field):
        return self.format[field]

    def get_gt_string(self):
       g_list = list()
       for f in self.variant.format_list:
           if f.id in self.variant.active_formats:
               if f.id in self.format:
                   if type(self.format[f.id]) == float:
                       g_list.append('%0.2f' % self.format[f.id])
                   else:
                       g_list.append(self.format[f.id])
               else:
                   g_list.append('.')
       return ':'.join(map(str,g_list))


@@ -184,32 +184,33 @@
   def set_format
+s
 (self, field, va
@@ -209,15 +209,17 @@
 ield
+s
 , value
+s
 ):%0A 
@@ -229,31 +229,475 @@
     
-if field in %5Bi.id for i
+for field, value in zip(fields, values):%0A            if field in self.variant.format_set:%0A                self.format%5Bfield%5D = value%0A            if field not in self.variant.active_formats:%0A                self.variant.active_formats.add(field)%0A        else:%0A            # FIXME This should be an exception%0A            sys.stderr.write('%5CnError: invalid FORMAT field, %5C%22' + field + '%5C%22%5Cn')%0A            exit(1)%0A%0A    def set_format(self, field, value):%0A        if field
  in 
@@ -720,13 +720,11 @@
 mat_
-list%5D
+set
 :%0A  

use set and set up method to set multiple formats at once