#!/usr/bin/env python

import sys, os, itertools, shutil, getopt, re 
import conf
import pdb, traceback
import metacomm.combinatorics.all_pairs2
all_pairs = metacomm.combinatorics.all_pairs2.all_pairs2

def do_Selfcom(self_combin_file,out_file):
    try:
        file = open(self_combin_file)
        allpairs_in = open(out_file,'a+')
        while 1:
            line = file.readline().replace("null","")
            line = line.replace(",,",",")
            if (line[-1:]==","):
              line = line[:-1]
            if not line:
                break
            allpairs_in.writelines(line + "\n")
        file.close()
        allpairs_in.close()
        return
    except Exception,e: 
        print Exception,":",e 
 
def fileline_count(fp):
     return len(open(fp).readlines()) 


def del_Seed(in_file):
    try:
        caseline = "" 
        old_list = []
        format_list =[]
        de=""
        row = 0
        file = open(in_file)
        items = []
        self_file = []
        s_name = p_name = ""
        if (os.path.isdir("self")):
            do_Clear(conf.path +"/self")
        os.mkdir(conf.path + "/self")
        while 1:
            p_name = s_name