Skip to content

Commit

Permalink
python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Lila committed Sep 14, 2018
1 parent 5e8751d commit 295d98e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 29 deletions.
10 changes: 6 additions & 4 deletions minimds.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion minimds_inter.py
Expand Up @@ -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()
Expand Down
24 changes: 0 additions & 24 deletions tad.py
Expand Up @@ -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

0 comments on commit 295d98e

Please sign in to comment.