from modeller import *

def load_rigid(path,mdl,sel_rigid,rand_rigid,rigid_filename):
    in_file = open(path + '/' + rigid_filename,"r")
    flag = 0
    while True:
        in_line = in_file.readline()
        if len(in_line) == 0:
            break
        in_line = in_line[:-1]
        if in_line[0] == 'h' or in_line[0] == 'b' or in_line[0] == 'l' or in_line[0] == 'd':
            continue
        elif in_line[0] == ' ':
            break
        else:
            resnum = [w for w in in_line.strip().split(' ') if len(w)]
            i=0
            list=selection()
            if resnum[-1] == 'nr':
                randflag = 0
                length = len(resnum) - 1
            else:
                randflag = 1
                length = len(resnum)
            while i < length:
                list.add(mdl.residue_range(resnum[i], resnum[i+1]))
                i=i+2
            sel_rigid.append(list)
            rand_rigid.append(randflag)
    in_file.close()
