#!/opt/gensoft/exe/hifix/1.0.6/venv/bin/python2.7

#    Copyright (C) 2011 CNRS
#    This file is part of HiFiX. 
#
#    HiFiX is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    HiFiX is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with HiFiX.  If not, see <http://www.gnu.org/licenses/>.

import sys
import os
import argparse
from hifixlib.MyUtils import mkdirTmp, cleanTmp
from hifixlib.HighFidelityX import algocore
       
def main():
    parser = argparse.ArgumentParser(description='High-Fidelity Clustering of Protein Sequences - Core')
       
    parser.add_argument('ID', action="store", help="prefix for required files ID.fasta and ID.net")
    parser.add_argument('PATH', action="store", help="absolute path where to find required files")
    
    parser.add_argument('-p', action="store", dest="path_to_louvain", default="",
                        help="absolute path to Louvain binaries, if not in the PATH environment variable")
    parser.add_argument('-n', action="store", dest="min", type=int, default=100,
                        help="minimum cluster size to be analyzed by HiFiX (default = 100)") 
    parser.add_argument('-d', action="store", dest="path_to_tmp", default=None,
                        help="specific directory (absolute path) where to build temporary files (optionnal, default temporary directory otherwise)")
    parser.add_argument('-i', action="store", dest="I", type=int, default=2,
                        help="number of most connected pairs in the merging step (time consuming, default=2)") 
    parser.add_argument('--version', action='version', version='%(prog)s 1.0.5')  
    options = parser.parse_args()    
          
    fid = options.ID
    inputdirectory = options.PATH
    min = int(options.min)
    workingdirectory = mkdirTmp(options.path_to_tmp)  
    algocore(fid, inputdirectory, workingdirectory, options.path_to_louvain, options.I)
    cleanTmp(workingdirectory)

if __name__ == '__main__':
    main()
