" already exist !!!!")
        exist = 1
    else:
        os.makedirs(correspondingCDSDir)
    if exist == 1:
        printCol.yellow("  Do you want to remove all analysis? (y/n)\n")
        inp = None
        while inp == None and inp != "y" and inp != "n" and inp != "yes" and inp != "no":
            inp = input()
            if inp == "y":
                os.popen('rm -r ' + correspondingCDSDir + '; mkdir ' +
                         correspondingCDSDir)
                exist = 0

            elif inp == "n":
                printCol.red(">>>Program exit\n")
                exit()

    # ouverture du fichier de résultat protine ortho pour construire liste de seq ortho
    with open(args.proteineOrthoFile, "r") as proteineOrthoFile:
        for line in proteineOrthoFile:
            if "#" not in line:
                tabline = line.split("\t")
                souche_contig1 = tabline[0]  # nom de la souche et contig
                souche_contig2 = tabline[1]
                namesouche1 = tabline[0].split("_")[0]  # nom de la souche seul
                namesouche2 = tabline[1].split("_")[0]

                if args.debug == "True":
                    print(souche_contig1, namesouche1, souche_contig2,
                          namesouche2)  # DEBUG
    tabNbPop = []
    tabNbRep = [
        repo.split("/")[-1].split("_")[-1] for repo in workingObjDir.listDir
        if "repetition" in repo
    ]
    for repo in workingObjDir.listDir:
        if "repetition" in repo:
            workingObjDirPop = directory(repo)
            tabNbPop = [
                repo.split("/")[-1].split("_")[-1]
                for repo in workingObjDirPop.listDir
            ]
            break
    if tabNbPop == []:
        printCol.red(
            "ERROR struc2runClumpak : path '%s' not contain folder 'repetition_*' with population sub-directory. Make sure take results product by script 'make_structure_dir.py' "
            % workingObjDir.pathDirectory)
        exit()
    tabNbRepSort = sorted(tabNbRep, key=int)
    tabNbPopSort = sorted(tabNbPop, key=int)
    nbRep, nbPop = len(tabNbRep), len(tabNbPop)
    print("There are %i repetition of %i population" % (nbRep, nbPop))

    # build label files
    print("Build label files into %s" % workingObjDir.pathDirectory)
    labelFile, labelAtopFile, orderlist = buildLabelFile(
        labelFileParam, workingObjDir.pathDirectory)
    print("Number of indiv in orderList: %s\n" % len(orderlist))

    print("Reorder files tab\n")
Exemple #3
0
##################################################
#Import MODULES_SEB
import sys, os
current_dir = os.path.dirname(os.path.abspath(__file__))+"/"
sys.path.insert(1,current_dir+'../modules/')
from MODULES_SEB import dict2txt, loadInList, dictDict2txt, printCol, relativeToAbsolutePath, existant_file, directory

## Python modules
import argparse
from time import localtime, strftime
import gzip

try:
	import egglib3 as egglib
except Exception as e:
	printCol.red(str(e))
	printCol.red("Must run :\nmodule load compiler/gcc/4.9.3")
	exit()


##################################################
## Variables Globales
version="0.1"
VERSION_DATE='28/02/2017'


##################################################
## Main code
##################################################
if __name__ == "__main__":