Пример #1
0
    def pro_chargepath(self,file):
        """parse charge_path

        Here may have bugs if the input is not generated by the Gaussian.

        Formats:

            nm  atomtype    charge
            1     C           0.1
            2     H           0.2
            3     O          -0.2

            Only three columns are used.
                1st :   input index
                2nd :   atom type   (ignored)
                3rd :   value

            Otherwise,
                Warning will be printed
        """
        self.charge_path = file
        file_size_check(self.charge_path,fsize=100)

        datalist = []
        with open(self.charge_path,mode='rt') as f:
            while True:
                line = f.readline()
                if len(line) == 0:
                    break

                sub = line[:line.find('#')] if line.find('#') != -1 else line
                lst = sub.split()
                if len(lst) == 0: continue

                if len(lst) == 3:
                    try:
                        n = int(lst[0])
                        v = float(lst[2])
                    except ValueError:
                        print(line)
                        raise ValueError('wrong defined line')
                    if n <= self.atomnm:
                        datalist.append(v)
                else:
                    print('Warning: ignoring ' + line)

        if len(datalist) % self.atomnm != 0:
            raise ValueError('not corresponded: atomnm & charge_path')

        # to avoid using an extra numpy module
        # works similar like;
        # numpy.array(datalist).reshape(len(datalist)//self.atomnm,self.atomnm)
        self.profile = []
        i = 0
        while i < len(datalist):
            ls = []
            for j in range(self.atomnm):
                ls.append(datalist[i])
                i += 1
            self.profile.append(ls)
Пример #2
0
    def __init__(self, *args, **kwargs):
        if 'toppath' in kwargs and kwargs['toppath'] is not None:
            self.toppath = kwargs['toppath']
            file_size_check(self.toppath, fsize=10)
        else:
            raise ValueError('toppath is missing')

        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.file_path = kwargs['file_path']
            file_size_check(self.file_path, fsize=500)
        else:
            raise ValueError('file_path is missing')

        self.pro_toppath(self.toppath)
        self.pro_file_path(self.file_path)

        if 'select_range' in kwargs and kwargs['select_range'] is not None:
            try:
                self.select_range = float(kwargs['select_range'])
                if self.select_range <= 0:
                    raise ValueError
            except ValueError:
                raise ValueError('select_range has to be a positive number')
        else:
            self.select_range = 10

        if 'reschoose' in kwargs and kwargs['reschoose'] is not None:
            tmp = kwargs['reschoose'].strip()
            self.reschoose = 'all' if len(tmp) == 0 else tmp.lower()
        else:
            self.reschoose = 'all'

        if 'gennm' in kwargs and kwargs['gennm'] is not None:
            try:
                self.gennm = int(kwargs['gennm'])
                if self.gennm <= 0: raise ValueError
            except ValueError:
                raise ValueError('gennm has to be positive integer')
        else:
            self.gennm = 5

        self.pro_selections()

        if 'basis_set' in kwargs and kwargs['basis_set'] is not None:
            self.basis_set = kwargs['basis_set'].strip()
        else:
            self.basis_set = '# HF/6-31G(d) Pop=CHelpG'

        if 'charge_spin' in kwargs and kwargs['charge_spin'] is not None:
            self.charge_spin = kwargs['charge_spin'].strip()
        else:
            self.charge_spin = '0 1'

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname'].strip()
        else:
            self.fname = 'GaussInput'
Пример #3
0
    def prochargepath(self, charge_path, in_keyword='ATOM'):
        """
        Parameter:
            charge_path     :   str | List[[float,float]]

        Returns:
            charge_list     :   List[[float,float], ...]
        """
        if isinstance(charge_path, list):
            # change the list name
            charge_list = charge_path
            for i in charge_list:
                if isinstance(i,list) and len(i) == 2 and \
                    isinstance(i[0],(float,int)) and isinstance(i[1],(float,int)):
                    pass
                else:
                    print('charge_path has to be a 2D nested number list')
                    print('its each sublist should only contain two indices')
                    raise ValueError('wrong defined')
        elif isinstance(charge_path, str):
            charge_list = []
            if len(charge_path.strip()) != 0:
                file_size_check(charge_path, fsize=100)
                with open(charge_path.strip(), mode='rt') as f:
                    while True:
                        line = f.readline()
                        if len(line) == 0:
                            break

                        sub = line if line.find(
                            '#') == -1 else line[:line.find('#')]
                        ltmp = sub.split()
                        bo = False
                        if len(ltmp) == 0:
                            continue
                        elif len(ltmp) == 4 and ltmp[0].upper() == in_keyword:
                            try:
                                t1 = float(ltmp[2])
                                t2 = float(ltmp[3])
                                charge_list.append([t1, t2])
                            except ValueError:
                                bo = True
                        else:
                            bo = True

                        if bo:
                            print(line)
                            raise ValueError('wrong defined, charge_path')
        else:
            raise ValueError('wrong defined, charge_path')

        return charge_list
Пример #4
0
    def profilepath(self):
        """process file_path based on self.error_tolerance

        Attributes:
            self.mlinlist
            self.totlist
        """
        file_size_check(self.file_path, fsize=500)
        profile = func_file_input(self.file_path,
                                  dtype=float,
                                  bool_tail=True,
                                  cut_keyword=self.cut_keyword,
                                  bool_force_cut_kw=True)

        self.mlinlist = []
        for i in profile:
            self.totlist.append(i[:-1])

            if self.error_tolerance == 'nan':
                self.mlinlist.append(i[:-1])
            elif isinstance(i[-1], (float, int)):
                if self.bool_abscomp and abs(i[-1]) <= self.error_tolerance:
                    self.mlinlist.append(i[:-1])
                elif i[-1] <= self.error_tolerance:
                    self.mlinlist.append(i[:-1])

        if len(self.mlinlist) < 5:
            print('the number of entry to be trained has to be no less than 5')
            raise ValueError('too less parameters')

        print('For error_tolerance: {:}'.format(self.error_tolerance))
        print('Number of ML_charge_list is: {:}'.format(len(self.mlinlist)))
        if self.bool_abscomp:
            print('Note: the absolute comparison is implemented')
        else:
            print('Note: the average comparison is implemented')
            print('      which may cause positive and negative cancellation')
        print('\nDo you want to continue? y/yes, else quit?', end='    ')

        get = input()
        if get.lower() not in ['y', 'yes']:
            print('Warning: you have decided to quit the ML charge generation')
            raise RuntimeError('user decided quit')
Пример #5
0
    def _f_pro_filepath(self):

        log = file_size_check(self.file_path, fsize=500)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return 0
        log, profile = function_file_input(self.file_path,
                                           dtype=float,
                                           bool_tail=True,
                                           cut_keyword=self.cut_keyword,
                                           bool_force_cut_kw=True)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return 0

        self.mlinlist = []
        for i in profile:
            self.totlist.append(i[:-1])

            if self.bool_abscomp and abs(i[-1]) <= self.error_tolerance:
                self.mlinlist.append(i[:-1])
            elif i[-1] <= self.error_tolerance:
                self.mlinlist.append(i[:-1])

        print('For the error_tolerance: {}'.format(self.error_tolerance))
        print('The selected number of ML_charge_list is: {:d}'.format(
            len(self.mlinlist)))
        if self.bool_abscomp:
            print('Note: the absolute comparison is implemented')
        else:
            print(
                'Note: the average comparison is implemented, which may cause positive and negative cancellation'
            )
        print('\nDo you want to continue? y/yes for continue, else quit?',
              end='    ')

        getinput = input()
        if getinput.upper() != 'Y' and getinput.upper() != 'YES':
            self.log['nice'] = False
            self.log['info'] = ''
            print(
                'Warning: you have decided to quit the ML charge generateion')
            return 0

        if len(self.mlinlist) < 5:
            self.log['nice'] = False
            self.log[
                'info'] = 'Error: for machine learning, the number of entry to be trained has to be no less than 5'
            return 0

        return 1
Пример #6
0
    def _f_pro_charge_path(self,charge_path):
        
        if isinstance(charge_path,list):
            # change the list name
            charge_list = charge_path
            if len(charge_path) == 0:
                print('Error: it seems the charge_path is a list, however, its length cannot be zero')
                exit()

            for i in charge_list:
                if isinstance(i,list) and len(i) == 2 and (isinstance(i[0],int) or isinstance(i[0],float)) \
                   and (isinstance(i[1],int) or isinstance(i[1],float)):
                    pass
                else:
                    self.log['nice'] = False
                    self.log['info'] = 'Error: the charge_path has to be a 2D nested number list\n' + \
                                           '       and its each sublist only contains two indices'
                    return 1        
                
        elif isinstance(charge_path,str):
            
            log = file_size_check(charge_path,fsize=100)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return 1
            
            charge_list = []
            with open(charge_path,mode='rt') as f:
                while True:
                    line = f.readline()
                    if len(line) == 0:
                        break
                    else:
                        ltmp = line[:line.find('#')].split()
                        if len(ltmp) != 0 and ltmp[0] == self.in_keyword:
                            ls = []
                            ls.append(float(ltmp[2]))
                            ls.append(float(ltmp[3]))
                            charge_list.append(ls)               
        return charge_list
Пример #7
0
    def _f_pro_charge_path(self, charge_path, charge_extend_by):
        """Randomly generate a new charge range based on the charge_extend_by parameters, the return values
           are normal charge_range and this new charge_range"""
        def bound_mutation(prolist, extend_by, des='string'):
            if len(prolist) == 0:
                self.log['nice'] = False
                self.log['info'] = 'Error: it seems the charge_path is a {:s}, however, nothing was input\n'.format(des) + \
                                   '     : Or it is not correctly defined'
                return 0

            newlist = []
            for i in prolist:

                vs = i[0] + (random.randrange(3) - 1) * extend_by
                vt = i[1] + (random.randrange(3) - 1) * extend_by

                ls = []
                if vt > vs:
                    ls.append(vs)
                    ls.append(vt)
                elif vt == vs:
                    ls.append(vs)
                    ls.append(vs + 0.1)
                else:
                    ls.append(vt)
                    ls.append(vs)

                newlist.append(ls)

            return newlist

        if isinstance(charge_path, list):
            for i in charge_list:
                if isinstance(i,list) and len(i) == 2 and (isinstance(i[0],int) or isinstance(i[0],float)) \
                   and (isinstance(i[1],int) or isinstance(i[1],float)):
                    pass
                else:
                    self.log['nice'] = False
                    self.log['info'] = 'Error: the charge_path has to be a 2D nested number list\n' + \
                                       '       and its each sublist only contains two indices'
                    return 0, 0

            # change the list name
            charge_nor_list = charge_path
            charge_new_list = bound_mutation(charge_path,
                                             charge_extend_by,
                                             des='list')

        elif isinstance(charge_path, str):

            log = file_size_check(charge_path, fsize=50)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return 0, 0

            charge_nor_list = []
            with open(charge_path, mode='rt') as f:
                while True:
                    line = f.readline()
                    if len(line) == 0:
                        break
                    else:
                        ltmp = line[:line.find('#')].split()
                        if len(ltmp) != 0 and ltmp[0] == 'ATOM':
                            ls = []
                            ls.append(float(ltmp[2]))
                            ls.append(float(ltmp[3]))
                            charge_nor_list.append(ls)
            charge_new_list = bound_mutation(charge_nor_list,
                                             charge_extend_by,
                                             des='file\'s path')

        else:
            self.log['nice'] = False
            self.log[
                'info'] = 'Error: the charge file has to be correctly defined'
            return 0, 0

        return charge_nor_list, charge_new_list
Пример #8
0
def pro_settingfile(settingfile):
    """Process the input settingfile"""
    def f_remove_comment(string):
        if string.find('#') == -1:
            return string.strip()
        return string[:string.find('#')]

    log = file_size_check(settingfile, fsize=5)
    if not log['nice']:
        print(log['info'])
        exit()

    # this universal string is used to exit prompt
    error_info = 'Error: the input setting file is wrong'

    infile = []
    with open(settingfile, mode='rt') as f:
        while True:
            line = f.readline()
            if len(line) == 0:
                break
            else:
                lt = line.split()
                if len(lt) == 0 or lt[0] == '#' or (len(lt[0]) > 1
                                                    and lt[0][0] == '#'):
                    continue
                else:
                    if line.find('=') == -1:
                        print(error_info)
                        print('Error line: ', line)
                        exit()
                    else:
                        lp = line.split('=', maxsplit=1)
                        partmp = lp[0].split()
                        if len(partmp) != 1:
                            print(error_info)
                            print('Error line: ', line)
                            exit()

                        parname = partmp[0].lower()

                        ls = []
                        ls.append(parname)

                        # take care of 'basis_set' comment exception
                        if parname != 'basis_set':

                            # take care of python representation string list to real python list
                            if parname == 'symmetry_list' or parname == 'counter_list' or \
                                 parname == 'offset_list' or parname == 'atomtype_list':
                                stmp = f_remove_comment(lp[1])
                                if len(stmp.split()) == 0:
                                    ls.append(None)
                                else:
                                    try:
                                        s = eval(stmp)
                                    except:
                                        print(
                                            'Error: the wrong defined python representation parameter'
                                        )
                                        print('Error line: ', line)
                                        exit()
                                    ls.append(s)

                            # take care of charge_spin exception
                            elif parname == 'charge_spin':
                                stmp = f_remove_comment(lp[1])
                                lr = stmp.split()
                                if len(lr) == 0:
                                    ls.append('0 1')
                                elif len(lr) == 2:
                                    ls.append(lr[0] + ' ' + lr[1])
                                else:
                                    print(
                                        'Error: the wrong definition of charge_spin parameter'
                                    )
                                    print('Error line: ', line)
                                    exit()

                            # take care of pn_limit exception
                            elif parname == 'pn_limit':
                                stmp = f_remove_comment(lp[1])
                                if len(stmp.split()) == 0:
                                    ls.append(None)
                                else:
                                    ls.append(stmp)

                            else:
                                stmp = f_remove_comment(lp[1])
                                lr = stmp.split()
                                if len(lr) == 0:
                                    ls.append(None)
                                elif len(lr) == 1:
                                    ls.append(sub_eval(lr[0]))
                                else:
                                    print(error_info)
                                    print('Error line: ', line)
                                    exit()
                        else:
                            ndx_first = lp[1].find('#')
                            if ndx_first == -1:
                                ltmp = ''
                                for i in lp[1].split():
                                    ltmp += i + ' '
                                ls.append(ltmp)
                            elif ndx_first == len(lp[1]):
                                ls.append('#')
                            else:
                                ndx_second = lp[1][ndx_first + 1:].find('#')
                                if ndx_second == -1:
                                    ltmp = ''
                                    for i in lp[1].split():
                                        ltmp += i + ' '
                                    ls.append(ltmp)
                                else:
                                    ltmp = ''
                                    for i in lp[1][:ndx_first + ndx_second +
                                                   1].split():
                                        ltmp += i + ' '
                                    ls.append(ltmp)
                        infile.append(ls)

    # process the infile to different blocks
    i = 0
    profile = []
    while i < len(infile):

        ls = []
        if infile[i][0] == 'command':
            ls.append(infile[i])
            j = i + 1
            while j < len(infile) and infile[j][0] != 'command':
                ls.append(infile[j])
                j += 1

            profile.append(ls)
            i = j
        else:
            i += 1

    if len(profile) == 0:
        print('Error: no command is found')
        exit()

    # process the command
    prodict = []
    for i in profile:

        # check the command
        cmd = i[0][1].lower()
        if not (cmd in par_cmdlist):
            print('Error: the command < {:} > is not defined'.format(i[0][1]))
            exit()

        # ATTENTION! Because of the python 'functionality', here it is very important
        # to force python to make a new memory copy of list or dict 'reference'
        # to avoid any 'same-memory-reference' allocating

        for par in parname_list:
            if par['command'].lower() == cmd:
                break
        fgetdict = {**par}

        parlist = [j for j, s in fgetdict.items()]
        for name in i:
            if not name[0] in parlist:
                print('Error: the parameter is not defined')
                print('     : In command < {:} >'.format(fgetdict['command']))
                print('Error parameter: ', name[0])
                exit()
            else:
                fgetdict[name[0]] = name[1]

        prodict.append(fgetdict)

    return prodict
Пример #9
0
    def __init__(self, *args, **kwargs):
        if 'reschoose' in kwargs and kwargs['reschoose'] is not None:
            if isinstance(kwargs['reschoose'], str):
                if len(kwargs['reschoose'].strip()) != 0:
                    self.reschoose = kwargs['reschoose'].strip()
                else:
                    self.reschoose = 'ALL'
            else:
                print(kwargs['reschose'])
                raise ValueError('reschoose is wrong')
        else:
            self.reschoose = 'ALL'

        bo = False
        if 'toppath' in kwargs and kwargs['toppath'] is not None:
            if isinstance(kwargs['toppath'], str):
                if len(kwargs['toppath'].strip()) != 0:
                    self.toppath = kwargs['toppath'].strip()
                else:
                    bo = True
            else:
                bo = True
            file_size_check(self.toppath, fsize=50)
        else:
            bo = True
        if bo:
            raise ValueError('toppath is wrong')

        if 'in_keyword' in kwargs and kwargs['in_keyword'] is not None:
            if isinstance(kwargs['in_keyword'], str):
                if len(kwargs['in_keyword'].strip()) != 0:
                    self.in_keyword = kwargs['in_keyword'].strip()
                else:
                    self.in_keyword = 'PAIR'
            else:
                raise ValueError('in_keyword is wrong')
        else:
            self.in_keyword = 'PAIR'

        if 'cut_keyword' in kwargs and kwargs['cut_keyword'] is not None:
            if isinstance(kwargs['cut_keyword'], str):
                if len(kwargs['cut_keyword'].strip()) != 0:
                    self.cut_keyword = kwargs['cut_keyword'].strip()
                else:
                    self.cut_keyword = 'MAE'
            else:
                raise ValueError('cut_keyword is wrong')
        else:
            self.cut_keyword = 'MAE'

        if 'fname' in kwargs and kwargs['fname'] is not None:
            if isinstance(kwargs['fname'], str):
                if len(kwargs['fname'].strip()) != 0:
                    self.fname = kwargs['fname'].strip()
                else:
                    self.fname = 'GenGromacsTopfile'
            else:
                raise ValueError('fname is wrong')
        else:
            self.fname = 'GenGromacsTopfile'

        if 'charge_path' in kwargs and kwargs['charge_path'] is not None:
            # func_file_input
            charge_path = kwargs['charge_path']
            if isinstance(charge_path, str):
                file_size_check(charge_path, fsize=50)
                self.file_line_chargepath = charge_path
                self.prochargefile = func_file_input(
                    charge_path,
                    comment_char='#',
                    dtype=float,
                    bool_tail=False,
                    in_keyword=self.in_keyword,
                    cut_keyword=self.cut_keyword)
            elif isinstance(charge_path, list):
                self.check_list(charge_path)
                self.prochargefile = charge_path
                self.file_line_chargepath = 'Note: charge_path input is a list'
            else:
                print(charge_path)
                raise ValueError('charge_path is wrong')
        else:
            raise ValueError('charge_path is missing')

        bo = False
        # Note: gennm == 0 means outputs are equal to length of inputs
        if 'gennm' in kwargs and kwargs['gennm'] is not None:
            if isinstance(kwargs['gennm'], int):
                self.gennm = kwargs['gennm']
                if self.gennm < 0: bo = True
            elif isinstance(kwargs['gennm'], str):
                if len(kwargs['gennm'].split()) == 0:
                    self.gennm = 0
                else:
                    try:
                        self.gennm = int(kwargs['gennm'])
                        if self.gennm < 0: raise ValueError
                    except ValueError:
                        bo = True
            else:
                bo = True
        else:
            self.gennm = 0
        if bo:
            raise ValueError('gennm is wrong, it has to be a positive integer')

        if self.gennm == 0: self.gennm = len(self.prochargefile)
        if self.gennm < len(self.prochargefile):
            print('Warning: number of charge entries are larger than gennm')
        else:
            self.gennm = len(self.prochargefile)

        # Note: symmetry_list has to deduct 1 for python-list notation
        if 'symmetry_list' in kwargs and kwargs['symmetry_list'] is not None:
            self.check_symmetry(kwargs['symmetry_list'])
        else:
            self.symmetry_list = []

        self.pro_topfile(self.toppath)

        # check the relation topfile with symmetry_list
        if self.symmetry_list is None or len(self.symmetry_list) == 0:
            self.symmetry_list = list(range(len(self.atomndx)))
        elif len(self.atomndx) < self.symmetry_length:
            raise ValueError('symmetry_list & topfile are not corresponded')
        elif len(self.atomndx) > self.symmetry_length:
            print('Note: only first residue is going to be changed')

        # check the relation chargefile with symmetry_list
        count = 1
        lth = len(self.symmetry_list)
        ls = []
        for i in self.prochargefile[:self.gennm]:
            if len(i) < lth:
                raise ValueError(
                    'symmetry_list & topfile are not corresponded')
            elif len(i) > lth:
                ls.append(count)
            count += 1

        if len(ls) > 0:
            print('Warning: number of charges are larger atoms in the topfile')
            print('       : truncation will happen')
            print('       : the number of this charge pair is:')
            for count in ls:
                print(count, end='   ')
            print()
Пример #10
0
    def __init__(self, **kwargs):
        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.filepath = kwargs['file_path'].strip()
            file_size_check(self.filepath, fsize=200)
        else:
            raise ValueError('no inputs')

        if 'stepsize' in kwargs and kwargs['stepsize'] is not None:
            try:
                self.stepsize = float(kwargs['stepsize'])
                if self.stepsize <= 0:
                    raise ValueError
            except ValueError:
                print('stepsize has to be a positive number')
                raise ValueError('wrong defined')
        else:
            self.stepsize = 0.01

        if 'percent' in kwargs and kwargs['percent'] is not None:
            try:
                self.percent = float(kwargs['percent'])
                if self.percent <= 0 or self.percent > 1:
                    raise ValueError
            except ValueError:
                print('percent has to be a number within the range 0 to 1')
                raise ValueError('wrong defined')
        else:
            self.percent = 0.95

        if 'error_tolerance' in kwargs and kwargs[
                'error_tolerance'] is not None:
            try:
                self.error_tolerance = float(kwargs['error_tolerance'])
            except ValueError:
                print('error_tolerance has to be a number')
                raise ValueError('wrong defined')
        else:
            self.error_tolerance = 0.28

        if 'bool_abscomp' in kwargs:
            self.bool_abscomp = False if kwargs[
                'bool_abscomp'] is False else True
        else:
            self.bool_abscomp = True

        if 'cut_keyword' in kwargs and kwargs['cut_keyword'] is not None:
            self.cut_keyword = kwargs['cut_keyword'].strip()
            if len(self.cut_keyword) == 0: self.cut_keyword = 'MAE'
        else:
            self.cut_keyword = 'MAE'

        if 'pallette_nm' in kwargs and kwargs['pallette_nm'] is not None:
            try:
                self.pallette_nm = int(kwargs['pallette_nm'])
                if self.pallette_nm <= 0:
                    raise ValueError
            except ValueError:
                print('pallette_nm has to be a positive integer')
                raise ValueError('wrong defined')
        else:
            self.pallette_nm = 50

        if 'atomtype_list' in kwargs and kwargs['atomtype_list'] is not None:
            if isinstance(kwargs['atomtype_list'], list):
                if len(kwargs['atomtype_list']) == 0:
                    self.atomtype_list = None
                else:
                    self.atomtype_list = kwargs['atomtype_list']
            else:
                print('atomtype_list has to be a list')
                raise ValueError('wrong defined')
        else:
            self.atomtype_list = None

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname'].strip()
            if len(self.fname) == 0: self.fname = 'FSS_analysis'
        else:
            self.fname = 'FSS_analysis'

        if 'color_map' in kwargs and kwargs['color_map'] is not None:
            self.color_map = kwargs['color_map']
        else:
            self.color_map = 'rainbow'
Пример #11
0
    def __init__(self, *args, **kwargs):
        self.log = {
            'nice': True,
        }

        if 'toppath' in kwargs and kwargs['toppath'] is not None:
            self.toppath = kwargs['toppath']
            log = file_size_check(self.toppath, fsize=10)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: the parameter toppath is missing'
            return

        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.file_path = kwargs['file_path']
            log = file_size_check(self.file_path, fsize=500)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: the parameter file_path is missing'
            return

        self._f_pro_toppath(self.toppath)
        if not self.log['nice']: return

        self._f_pro_file_path(self.file_path)
        if not self.log['nice']: return

        self._f_remove_periodic()

        if 'select_range' in kwargs and kwargs['select_range'] is not None:
            try:
                self.select_range = float(kwargs['select_range'])
                if self.select_range <= 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter select_range has to be a positve number'
                return
        else:
            self.select_range = 10

        self._f_pro_selections()

        if 'gennm' in kwargs and kwargs['gennm'] is not None:
            try:
                self.gennm = int(kwargs['gennm'])
                if self.gennm > len(self.prolist) or self.gennm <= 0:
                    self.gennm = len(self.prolist)
            except ValueError:
                self.log['nice'] = False
                self.log['info'] = 'Error: the parameter gennm has to be a number\n' + \
                                   'Error gennm: ' + kwargs['gennm']
                return
        elif len(self.prolist) < 5:
            self.gennm = len(self.prolist)
        else:
            self.gennm = 5

        self._f_random_selections()

        if 'basis_set' in kwargs and kwargs['basis_set'] is not None:
            self.basis_set = kwargs['basis_set']
        else:
            self.basis_set = '# HF/6-31G(d) Pop=CHelpG'

        if 'charge_spin' in kwargs and kwargs['charge_spin'] is not None:
            self.charge_spin = str(kwargs['charge_spin'])
        else:
            self.charge_spin = '0 1'

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = str(kwargs['fname'])
        else:
            self.fname = 'GaussInput'

        self._prefile()
        if not self.log['nice']: return
Пример #12
0
    def __init__(self,*args,**kwargs):
        self.log = {'nice':True,}

        bo = False
        if 'atomnm' in kwargs and kwargs['atomnm'] is not None:
            try:
                self.atomnm = int(kwargs['atomnm'])
                if self.atomnm <= 0:
                    raise ValueError
            except ValueError:
                bo = True
                self.log['info'] = 'Error: the parameter atomnm has to be a positive number'
        else:
            bo = True
            self.log['info'] = 'Error: the parameter atomnm is missing'
        if bo:
            self.log['nice'] = False
            return


        if 'charge_path' in kwargs and kwargs['charge_path'] is not None:
            """ATTENTION! Here may have bugs, if the input charge_file_path is not
               generated by the Gaussian. The follow shows the file format:

               nm  atomtype    charge
               1     C           0.1
               2     H           0.2
               3     O          -0.2

               Only three columns are used. The first column is the input index,
               the second column is the atom-type, the last one is the value"""

            self.charge_path = kwargs['charge_path']
            mcp = file_size_check(self.charge_path,fsize=100)
            if not mcp['nice']:
                self.log['nice'] = False
                self.log['info'] = mcp['info']
                return

            datalist = []
            with open(self.charge_path,mode='rt') as f:
                while True:
                    line = f.readline()
                    if len(line) == 0:
                        break
                    else:
                        lst = line[:line.find('#')].split()
                        if len(lst) == 3 and int(lst[0]) <= self.atomnm:
                            datalist.append(float(lst[2]))

            if len(datalist) % self.atomnm != 0:
                self.log['nice'] = False
                self.log['info'] = 'Error: wrong input_data_file or atom_number\n' + \
                                       'Error: input charge_file_path: ' + self.charge_path + '\n' + \
                                       'Error input atom_number: ' + str(self.atomnm)
                return

            # to avoid using an extra numpy module
            # works similar like;
            #     numpy.array(datalist).reshape(len(datalist)//self.atomnm,self.atomnm)
            self.profile = []
            i = 0
            while i < len(datalist):
                ls = []
                j = 0
                while j < self.atomnm:
                    ls.append(datalist[i])
                    i += 1
                    j += 1
                self.profile.append(ls)
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: the parameter charge_path is missing'
            return
 
        
        if 'percent' in kwargs and kwargs['percent'] is not None:
            try:
                self.percent = float(kwargs['percent'])
                if self.percent > 1.0 or self.percent <= 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log['info'] = 'Error: the parameter percent has to be a positive number\n' + \
                                   '     : and its value must fall within in (0,1]'
                return
        else:
            self.percent = 0.8
            
            
        if 'stepsize' in kwargs and kwargs['stepsize'] is not None:
            try:
                self.stepsize = float(kwargs['stepsize'])
                if self.stepsize <= 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log['info'] = 'Error: the parameter stepsize has to be a positive number'
                return            
        else:
            self.stepsize = 0.01

            
        if 'nmround' in kwargs and kwargs['nmround'] is not None:
            try:
                self.nmround = int(kwargs['nmround'])
                if self.nmround < 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log['info'] = 'Error: the parameter nmround has to be a positive integer'
                return
        else:
            self.nmround = 3

            
        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = str(kwargs['fname'])
        else:
            self.fname = 'ChargeGenRange'
Пример #13
0
    def __init__(self, *args, **kwargs):
        self.log = {
            'nice': True,
        }

        if 'reschoose' in kwargs and kwargs['reschoose'] is not None:
            self.reschoose = kwargs['reschoose']
        else:
            self.reschoose = 'All'

        if 'toppath' in kwargs and kwargs['toppath'] is not None:
            self.toppath = kwargs['toppath']
            log = file_size_check(self.toppath, fsize=50)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return
            fp = self._f_pro_topfile(self.toppath)
            if not self.log['nice']: return
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: the parameter toppath is missing'
            return

        if 'in_keyword' in kwargs and kwargs['in_keyword'] is not None:
            self.in_keyword = kwargs['in_keyword']
        else:
            self.in_keyword = 'PAIR'

        if 'cut_keyword' in kwargs and kwargs['cut_keyword'] is not None:
            self.cut_keyword = kwargs['cut_keyword']
        else:
            self.cut_keyword = 'MAE'

        if 'charge_path' in kwargs and kwargs['charge_path'] is not None:
            # function_file_input
            charge_path = kwargs['charge_path']
            if isinstance(charge_path, str):
                log = file_size_check(charge_path, fsize=50)
                if not log['nice']:
                    self.log['nice'] = False
                    self.log['info'] = log['info']
                    return
                self.file_line_chargepath = charge_path

                log, self.prochargefile = function_file_input(
                    charge_path,
                    comment_char='#',
                    dtype=float,
                    bool_tail=False,
                    in_keyword=self.in_keyword,
                    cut_keyword=self.cut_keyword)
                if not log['nice']:
                    self.log['nice'] = False
                    self.log['info'] = log['info']
                    return

            elif isinstance(charge_path, list):
                dump_value = self._f_list_dcheck(charge_path)
                if not self.log['nice']: return
                self.prochargefile = charge_path
                self.file_line_chargepath = 'Note: charge_path input is a list'

            else:
                self.log['nice'] = False
                self.log['info'] = 'Error: wrong defined charge_path parameter\n' + \
                                   'Error: it only can either be a list or a real file path'
                return
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: the parameter charge_path is missing'
            return

        if 'gennm' in kwargs and kwargs['gennm'] is not None:
            try:
                self.gennm = int(kwargs['gennm'])

                if self.gennm == 0 or self.gennm > len(self.prochargefile):
                    self.gennm = len(self.prochargefile)
                elif self.gennm < 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log['info'] = 'Error: the gennm has to be a positive integer\n' + \
                                   'Error gennm: '+ str(kwargs['gennm'])
                return
        else:
            self.gennm = len(self.prochargefile)

        if 'symmetry_list' in kwargs:
            symmetry_list = kwargs['symmetry_list']
        else:
            symmetry_list = None

        ndx = len(self.atomndx)
        if symmetry_list is None:
            symmetry_list = list(range(ndx))
            symmetry_length = ndx
            self.file_line_symmetry = None

        elif isinstance(symmetry_list, list):
            if len(symmetry_list) == 0:
                symmetry_list = list(range(ndx))
                symmetry_length = ndx
                self.file_line_symmetry = None
            else:
                _par = Pro_list(symmetry_list=symmetry_list)
                if not _par.log['nice']:
                    self.log['nice'] = False
                    self.log['info'] = _par.log['info']
                    return
                symmetry_list = _par.symmetry_list
                symmetry_length = _par.symmetry_length
                self.file_line_symmetry = _par.file_line_symmetry
        else:
            self.log['nice'] = False
            self.log[
                'info'] = 'Error: the parameter symmetry_list has to be a list'
            return

        if symmetry_length > ndx:
            self.log['nice'] = False
            self.log[
                'info'] = 'Error: the symmetry_list and topfile are not corresponded'
            return

        count = 1
        lth = len(symmetry_list)
        ls = []
        for i in self.prochargefile[:self.gennm]:
            if len(i) < lth:
                print('Error: the chargefile and topfile are not corresponded')
                exit()
            elif len(i) > lth:
                ls.append(count)
            count += 1

        if len(ls) > 0:
            print(
                'Warning: the number of charges are bigger than the atom numbers in the topfile'
            )
            print(
                '       : truncation will happen, only the number of leading charges will be used'
            )
            print('       : the number of this charge pair is:')
            for count in ls:
                print(count, end='   ')
            print()

        self.refatomtype = []
        for i in symmetry_list:
            if isinstance(i, int):
                line = self.protopfile[self.atomndx[i]]
                self.refatomtype.append(line.split()[1])
            else:
                line_1 = self.protopfile[self.atomndx[i[0]]]
                atype = line_1.split()[1]
                if len(i) > 1:
                    for j in i[1:]:
                        line = self.protopfile[self.atomndx[j]]
                        if atype != line.split()[1]:
                            self.log['nice'] = False
                            self.log['info'] = 'Error: the atom_types under [atoms] directive in top file is not equivalent\n' + \
                                               'Error: symmetry_list:' + line_1[:-1] + '\n' + \
                                               line[:-1]
                            return
                self.refatomtype.append(atype)

        dump_value = self._generator()
        if not self.log['nice']: return

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname']
        else:
            self.fname = 'GenGromacsTopfile'
Пример #14
0
    def __init__(self, *args, **kwargs):
        self.log = {
            'nice': True,
        }
        if 'file_path' not in kwargs or kwargs['file_path'] is None:
            self.log['nice'] = False
            self.log['info'] = 'Error: no file inputs'
            return
        self.file = kwargs['file_path']
        log = file_size_check(self.file, fsize=2)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return

        self.fname = 'PAIR_Charge'
        self.parameters = {
            'top_gas_path': None,
            'top_liq_path': None,
            'top_fep_path': None,
            'gro_gas_path': None,
            'gro_liq_path': None,
            'gro_fep_path': None,
            'grompp_min_gas_path': None,
            'grompp_min_liq_path': None,
            'grompp_nvt_liq_path': None,
            'grompp_npt_liq_path': None,
            'grompp_prod_gas_path': None,
            'grompp_prod_liq_path': None,
            'grompp_fep_min_steep_path': None,
            'grompp_fep_min_lbfgs_path': None,
            'grompp_fep_nvt_path': None,
            'grompp_fep_npt_path': None,
            'grompp_fep_prod_path': None,
            'charge_range_path': None,
            'gromacs_energy_kw': 'Density',
            'literature_value': 1000,
            'gmx': 'gmx',
            'MAE': 0.05,
            'training_total_nm': 5,
            'training_cnt': 1,
            'gennm': 10,
            'error_tolerance': 0.5,
            'symmetry_list': None,
            'pn_limit': None,
            'counter_list': None,
            'offset_list': None,
            'offset_nm': None,
            'ratio': None,
            'nmround': None,
            'total_charge': 0.0,
            'charge_extend_by': None,
            'threshold': None,
            'bool_neutral': None,
            'bool_nozero': None,
            'bool_abscomp': None,
            'reschoose': None,
            'analysis_begintime': None,
            'analysis_endtime': None,
        }

        self._profile()
        if not self.log['nice']: return
        self._proparameters()
        if not self.log['nice']: return
        self._try_file_generations()
        if not self.log['nice']: return

        # check for the bash scripts
        if 'bashinterfile' in kwargs and kwargs['bashinterfile'] is not None:
            self.bashinterfile = kwargs['bashinterfile']
            log = file_size_check(self.bashinterfile, fsize=10)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return
            with open(self.bashinterfile, mode='rt') as f:
                self._shfile = f.read()
        else:
            self.bashinterfile = 'GAML-BASH-Interface.sh'
            self._shfile = resource_string(
                __name__,
                'shell/' + self.bashinterfile).decode('utf-8').replace(
                    '\r', '')
Пример #15
0
    def __init__(self, *args, **kwargs):
        if 'file_path' not in kwargs or kwargs['file_path'] is None:
            raise ValueError('no inputs, file_path is missing')
        self.file = kwargs['file_path'].strip()
        file_size_check(self.file, fsize=2)

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname'].strip()
            if len(self.fname) == 0: self.fname = 'bash_GAML_AutoTraining'
        else:
            self.fname = 'bash_GAML_AutoTraining'

        self.parameters = {
            'top_gas_path': None,
            'top_liq_path': None,
            'top_fep_path': None,
            'gro_gas_path': None,
            'gro_liq_path': None,
            'gro_fep_path': None,
            'grompp_min_gas_path': None,
            'grompp_min_liq_path': None,
            'grompp_nvt_liq_path': None,
            'grompp_npt_liq_path': None,
            'grompp_prod_gas_path': None,
            'grompp_prod_liq_path': None,
            'grompp_fep_min_steep_path': None,
            'grompp_fep_min_lbfgs_path': None,
            'grompp_fep_nvt_path': None,
            'grompp_fep_npt_path': None,
            'grompp_fep_prod_path': None,
            'charge_range_path': None,
            'gromacs_energy_kw': 'Density',
            'literature_value': 1000,
            'gmx': 'gmx',
            'MAE': 0.05,
            'training_total_nm': 5,
            'training_cnt': 1,
            'gennm': 10,
            'error_tolerance': 0.5,
            'symmetry_list': None,
            'pn_limit': None,
            'counter_list': None,
            'offset_list': None,
            'offset_nm': None,
            'ratio': None,
            'nmround': None,
            'total_charge': 0.0,
            'charge_extend_by': None,
            'threshold': None,
            'bool_neutral': None,
            'bool_nozero': None,
            'bool_abscomp': None,
            'reschoose': None,
            'analysis_begintime': None,
            'analysis_endtime': None,
        }

        # check for the bash scripts
        bo = True
        if 'bashinterfile' in kwargs and kwargs['bashinterfile'] is not None:
            self.bashinterfile = kwargs['bashinterfile'].strip()
            if len(self.bashinterfile) == 0:
                self.bashinterfile = 'GAML-BASH-Interface.sh'
            else:
                bo = False
        else:
            self.bashinterfile = 'GAML-BASH-Interface.sh'

        if bo:
            self.shfile = resource_string(
                __name__,
                'scripts/' + self.bashinterfile).decode('utf-8').replace(
                    '\r', '')
        else:
            file_size_check(self.bashinterfile, fsize=10)
            with open(self.bashinterfile, mode='rt') as f:
                self.shfile = f.read()

        self.profile()
        self.proparameters()
        self.trial()
Пример #16
0
    def __init__(self, **kwargs):
        self.log = {
            'nice': True,
        }

        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.filepath = kwargs['file_path']
            log = file_size_check(self.filepath, fsize=200)
            if not log['nice']:
                self.log['nice'] = False
                self.log['info'] = log['info']
                return
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: no file inputs'
            return

        if 'stepsize' in kwargs and kwargs['stepsize'] is not None:
            try:
                self.stepsize = float(kwargs['stepsize'])
                if self.stepsize <= 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter stepsize has to be a positive number'
                return
        else:
            self.stepsize = 0.01

        if 'percent' in kwargs and kwargs['percent'] is not None:
            try:
                self.percent = float(kwargs['percent'])
                if self.percent <= 0 or self.percent > 1:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter percent has to be a positive number within the range 0 to 1'
                return
        else:
            self.percent = 0.95

        if 'error_tolerance' in kwargs and kwargs[
                'error_tolerance'] is not None:
            try:
                self.error_tolerance = float(kwargs['error_tolerance'])
            except ValueError:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter error_tolerance has to be a number'
                return
        else:
            self.error_tolerance = 0.28

        if 'bool_abscomp' in kwargs:
            self.bool_abscomp = False if kwargs[
                'bool_abscomp'] is False else True
        else:
            self.bool_abscomp = True

        if 'cut_keyword' in kwargs and kwargs['cut_keyword'] is not None:
            self.cut_keyword = kwargs['cut_keyword']
        else:
            self.cut_keyword = 'MAE'

        if 'pallette_nm' in kwargs and kwargs['pallette_nm'] is not None:
            try:
                self.pallette_nm = int(kwargs['pallette_nm'])
                if self.pallette_nm <= 0:
                    raise ValueError
            except ValueError:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter pallette_nm has to be a positive integer'
                return
        else:
            self.pallette_nm = 50

        if 'atomtype_list' in kwargs and kwargs['atomtype_list'] is not None:
            if isinstance(kwargs['atomtype_list'], list):
                if len(kwargs['atomtype_list']) == 0:
                    self.atomtype_list = None
                else:
                    self.atomtype_list = kwargs['atomtype_list']
            else:
                self.log['nice'] = False
                self.log[
                    'info'] = 'Error: the parameter atomtype_list has to be a list'
                return
        else:
            self.atomtype_list = None

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname']
        else:
            self.fname = 'FSS_analysis'

        if 'color_map' in kwargs and kwargs['color_map'] is not None:
            self.color_map = kwargs['color_map']
        else:
            self.color_map = 'rainbow'

        self._function_ready()
        if not self.log['nice']: return
Пример #17
0
    def __init__(self, *args, **kwargs):
        self.log = {
            'nice': True,
        }
        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.file = kwargs['file_path']
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: no file input'
            return
        log = file_size_check(self.file, fsize=100)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return

        if 'chargefile' in kwargs and kwargs['chargefile'] is not None:
            self.chargefile = kwargs['chargefile']
        else:
            self.log['nice'] = False
            self.log['info'] = 'Error: no charge file input'
            return
        log = file_size_check(self.chargefile, fsize=100)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return
        log, self.prochargefile = function_file_input(self.chargefile,
                                                      bool_tail=False)
        if not log['nice']:
            self.log['nice'] = False
            self.log['info'] = log['info']
            return

        if 'kwlist' in kwargs and kwargs['kwlist'] is not None:
            if len(kwargs['kwlist']) != 0:
                self.kwlist = kwargs['kwlist']
            else:
                self.kwlist = ['Density']
        else:
            self.kwlist = ['Density']

        if 'bool_gas' in kwargs and kwargs['bool_gas'] is not None:
            self.bool_gas = True if kwargs['bool_gas'] is True else False
        else:
            self.bool_gas = False
        if self.bool_gas and 'Potential' not in self.kwlist:
            self.kwlist.append('Potential')
        if 'Potential' in self.kwlist: self.bool_gas = True

        if 'temperature' in kwargs and kwargs['temperature'] is not None:
            try:
                self.temperature = float(kwargs['temperature'])
            except ValueError:
                self.temperature = 298.0
        else:
            self.temperature = 298.0

        if 'block' in kwargs and kwargs['block'] is not None:
            self.block = kwargs['block']
        else:
            self.block = 'COUNT'

        self.literature_value = []
        if 'literature_value' in kwargs and kwargs[
                'literature_value'] is not None:
            for nm in kwargs['literature_value']:
                try:
                    t = float(nm)
                    self.literature_value.append(t)
                except ValueError:
                    pass
        if len(self.literature_value) == 0:
            self.log['nice'] = False
            self.log['info'] = 'Error: no literature value inputs'
            return

        if len(self.literature_value) < len(self.kwlist):
            print(
                'Warning: the number of properties in kwlist are bigger than\n'
            )
            print(
                '       : the number of literature value inputs, truncation\n')
            print('       : will happen')
            self.kwlist = self.kwlist[:len(self.literature_value)]
        elif len(self.literature_value) > len(self.kwlist):
            print(
                'Warning: the number of literature value inputs are bigger\n')
            print('       : than the number of properties in kwlist,\n')
            print('       : truncation will happen')
            self.literature_value = self.literature[:len(self.kwlist)]

        if 'atomnm' in kwargs and kwargs['atomnm'] is not None:
            try:
                self.atomnm = int(float(kwargs['atomnm']))
            except ValueError:
                self.atomnm = 500
        else:
            self.atomnm = 500

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname']
        else:
            self.fname = 'MAE_PAIR'

        if 'MAE' in kwargs and kwargs['MAE'] is not None:
            try:
                self.MAE = float(kwargs['MAE'])
            except ValueError:
                self.MAE = 0.05
        else:
            self.MAE = 0.05

        self._profile()
        self._pro_bool_gas()
Пример #18
0
    def __init__(self, *args, **kwargs):
        if 'file_path' in kwargs and kwargs['file_path'] is not None:
            self.file = kwargs['file_path'].strip()
            file_size_check(self.file, fsize=100)
        else:
            raise ValueError('no inputs, file_path is missing')

        if 'chargefile' in kwargs and kwargs['chargefile'] is not None:
            self.chargefile = kwargs['chargefile'].strip()
            file_size_check(self.chargefile, fsize=100)
        else:
            raise ValueError('no inputs, chargefile is missing')
        self.prochargefile = func_file_input(self.chargefile, bool_tail=False)

        if 'kwlist' in kwargs and kwargs['kwlist'] is not None:
            if isinstance(kwargs['kwlist'],
                          list) and len(kwargs['kwlist']) != 0:
                self.kwlist = [i.lower() for i in kwargs['kwlist']]
            else:
                self.kwlist = ['density']
        else:
            self.kwlist = ['density']

        if 'bool_gas' in kwargs and kwargs['bool_gas'] is not None:
            self.bool_gas = True if kwargs['bool_gas'] is True else False
        else:
            self.bool_gas = False
        if self.bool_gas and 'potential' not in self.kwlist:
            self.kwlist.append('potential')
        if 'potential' in [i.lower() for i in self.kwlist]:
            self.bool_gas = True

        if 'temperature' in kwargs and kwargs['temperature'] is not None:
            try:
                self.temperature = float(kwargs['temperature'])
            except ValueError:
                self.temperature = 298.0
        else:
            self.temperature = 298.0

        if 'block' in kwargs and kwargs['block'] is not None:
            if isinstance(kwargs['block'], str):
                self.block = kwargs['block'].strip().lower()
            else:
                self.block = 'count'
        else:
            self.block = 'count'

        self.literature_value = []
        if 'literature_value' in kwargs and kwargs[
                'literature_value'] is not None:
            for nm in kwargs['literature_value']:
                try:
                    t = float(nm)
                    self.literature_value.append(t)
                except ValueError:
                    print(kwargs['literature_value'])
                    raise ValueError('wrong defined')
        if len(self.literature_value) == 0:
            raise ValueError('no inputs, literature_value is missing')

        self.literature_value, self.kwlist = self._checknm(
            self.literature_value, 'literature_value', self.kwlist, 'kwlist')

        if 'atomnm' in kwargs and kwargs['atomnm'] is not None:
            try:
                self.atomnm = int(float(kwargs['atomnm']))
            except ValueError:
                self.atomnm = 500
        else:
            self.atomnm = 500

        if 'fname' in kwargs and kwargs['fname'] is not None:
            self.fname = kwargs['fname'].strip()
            if len(self.fname) == 0: self.fname = 'MAE_PAIR'
        else:
            self.fname = 'MAE_PAIR'

        if 'MAE' in kwargs and kwargs['MAE'] is not None:
            try:
                self.MAE = float(kwargs['MAE'])
            except ValueError:
                self.MAE = 0.05
        else:
            self.MAE = 0.05