diff --git a/minimds.py b/minimds.py index 90dc895..7032ddf 100644 --- a/minimds.py +++ b/minimds.py @@ -21,6 +21,8 @@ def infer_structure(contactMat, structure, alpha, num_threads, classical=False): distMat = at.contactToDist(contactMat, alpha) at.makeSymmetric(distMat) + distMat = distMat/np.mean(distMat) #normalize + if classical: #classical MDS coords = la.cmds(distMat) else: @@ -76,11 +78,11 @@ def partitionedMDS(path, args): high_substructures.append(high_substructure) offset += len(high_substructure.points) #update offset -= 1 - + highstructure.setstructures(high_substructures) - + infer_structure(low_contactMat, lowstructure, alpha, num_threads) - print "Low-resolution MDS complete" + print("Low-resolution MDS complete") highSubstructures = pymp.shared.list(highstructure.structures) lowSubstructures = pymp.shared.list(lowstructure.structures) @@ -115,7 +117,7 @@ def partitionedMDS(path, args): highSubstructure.transform(r, t) highSubstructures[substructurenum] = highSubstructure - print "MDS performed on structure {} of {}".format(substructurenum + 1, numSubstructures) + print("MDS performed on structure {} of {}".format(substructurenum + 1, numSubstructures)) highstructure.setstructures(highSubstructures) diff --git a/minimds_inter.py b/minimds_inter.py index 14d9a14..3b02938 100644 --- a/minimds_inter.py +++ b/minimds_inter.py @@ -43,7 +43,7 @@ def get_inter_mat(prefix, inter_res_string, intra_res_string, structures, offset path = "{}_{}_{}.bed".format(prefix, names[i], intra_res_string) else: path = "{}_{}_{}_{}.bed".format(prefix, names[j], names[i], inter_res_string) - print "Reading {}".format(path) + print("Reading {}".format(path)) with open(path) as bed: for line in bed: line = line.strip().split() diff --git a/tad.py b/tad.py index e7f3ddd..f7e058d 100644 --- a/tad.py +++ b/tad.py @@ -110,27 +110,3 @@ def substructuresFromTads(structure, tads): points = structure.points[start-structure.offset:end-structure.offset] structure.createSubstructure(points, offset) offset = end #update - -#def substructuresFromTads(high_structure, low_structure, low_tads): -# """Create compatible substructures from TADs in high-res structure and low-res structure""" -# res_ratio = low_structure.chrom.res/high_structure.chrom.res -# high_tads = low_tads * res_ratio - # high_offset = 0 -# low_offset = 0 - # for high_tad, low_tad in zip(high_tads, low_tads): -# if high_tad[0] < len(high_structure.getPointNums()): -# high_start = high_structure.getPointNums()[high_tad[0]] #convert from index to num -# high_end = high_structure.getPointNums()[min((high_tad[1], len(high_structure.getPoints()) - 1))] #don't go out of bounds -# low_start = low_structure.getPointNums()[low_tad[0]] -# low_end = low_structure.getPointNums()[min((low_tad[1], len(low_structure.getPoints()) - 1))] -# high_points = high_structure.points[(high_start-high_structure.offset):(high_end-high_structure.offset)] -# low_points = low_structure.points[(low_start-low_structure.offset):(low_end-low_structure.offset)] -# high_nums = [high_point.num for high_point in high_points if high_point != 0] -# inferred_low_nums = np.array(high_nums)/res_ratio -# true_low_nums = [low_point.num for low_point in low_points if low_point != 0] -# intersection = [num for num in true_low_nums if num in inferred_low_nums] -# if len(intersection) > 0: #compatible -# high_structure.createSubstructure(high_points, high_offset) -# low_structure.createSubstructure(low_points, low_offset) -# high_offset = high_end -# low_offset = low_end