def load_reference_state(helper_path):
    """This function performs a one-time initialization for the reference state. Currently, this version uses a text file that provides the number of zones with the same distance range as each position zone in the first octant."""
    global radial_matches
    radial_matches = {}
    loading_indicator.add_loading_data(1)
    with open(helper_path, "r") as file:
        for line in file:
            comps = line.split(";")
            point = Point3D(*(float(x) for x in comps[0].split(",")))
            matches = int(comps[1])
            radial_matches[point] = matches
    loading_indicator.update_progress(1)
def load_possible_interactions(interactions_path):
    """Performs a one-time initialization for the reference contact frequencies of various amino acid types."""
    global possible_interactions
    paths = os.listdir(interactions_path)
    loading_indicator.add_loading_data(len(paths))
    for path in paths:
        loading_indicator.update_progress(1)
        if ".txt" not in path or path[0] == ".":
            continue
        tag1, tag2 = path[:-4].split("-")
        tag1 = int(tag1)
        tag2 = int(tag2)
        with open(os.path.join(interactions_path, path), "r") as file:
            for line in file:
                comps = line.split(";")
                if len(comps) < 2:
                    continue
                possible_interactions[tag1][tag2][float(comps[0])] = [int(x) for x in comps[1].split(",")]
	def load_frequencies(self, frequencies_path):
		files = os.listdir(frequencies_path)
		loading_indicator.add_loading_data(len(files))
		for indfile in files:
			loading_indicator.update_progress(1)
			if indfile.find(".txt") == -1: continue
			idx = int(indfile[0:-4])
			with open(join(frequencies_path, indfile), 'r') as file:
				for line in file:
					line = line.strip()
					if len(line) == 0: continue
					if "," not in line and " " not in line:
						if self.median_frequencies[idx] == 0.0:
							self.median_frequencies[idx] = float(line)
					else:
						if "," in line: comps = line.split(",")
						else: comps = line.split()
						coord = int(comps[0])
						self.frequencies[idx][coord] = float(comps[1])
		for idx in xrange(AMINO_ACID_COUNT):
			self.median_frequencies[idx] = sum(self.frequencies[idx])# / float(len([f for f in self.frequencies[idx] if f != 0]))