See the sweeper_output() method doctstring for format details.

def name_gen(self, as_number, k, diploid_mode):
        """See the sweeper_output() method doctstring for format details."""
        #how to add prefixes to numbers
        #http://stackoverflow.com/a/135157
        #         ai_d_z_g_s_k_p.config

        parts =  {"1ai": "{0}{1:03d}_".format(self.as_a, as_number),
                  "2d" : "{0}_".format(self.as_d),
                  "3z" : "ME_",
                  "4g" : "{}_".format(self.as_g) if self.as_g else "",
                  "5s" : "{}_".format(self.as_s) if self.as_s else "",
                  "6k" : "k{}_".format(k),
                  "7p" : "d{}".format(diploid_mode)}
        return "".join([parts.get(x) for x in sorted(parts)])