diff --git a/barnaba/functions.py b/barnaba/functions.py index d228077..47ef4c5 100644 --- a/barnaba/functions.py +++ b/barnaba/functions.py @@ -1236,57 +1236,36 @@ def parse_dotbracket(threshold, file, weights): # mult_chain = True if not line.startswith("#"): l = line.split() - if "pdb" in l[0].lower(): - dotbr = l[1] - if len(dotbr) != len(sequence): - print(mult_chain) - if not mult_chain: - sys.exit("Dot-bracket length does not match sequence length") - else: - dotbr = dotbr[:len(sequence)] - base_pairs = parse_dotbr(dotbr) - for bp in base_pairs: - ann_list[bp[0], bp[1], "WCc"] = 1. - list_base_pairs = base_pairs - ann_lists.append(dict(ann_list)) - ann_list = {} - else: - try: int(l[0]) - except ValueError: - continue + dotbr = l[1] + if len(dotbr) != len(sequence): + if not mult_chain: + sys.exit("Dot-bracket length does not match sequence length") else: - traj = True - dotbr = l[1] - if len(dotbr) != len(sequence): - if not mult_chain: - sys.exit("Dot-bracket length does not match sequence length") - else: - dotbr = dotbr[:len(sequence)] - n_frames += 1 - base_pairs = parse_dotbr(dotbr) - for bp in base_pairs: - if bp not in list_base_pairs: - list_base_pairs.append(bp) - try: - ann_list[bp[0], bp[1], "WCc"] - except: - if len(weights) == 0: - ann_list[bp[0], bp[1], "WCc"] = 1. - else: - ann_list[bp[0], bp[1], "WCc"] = weights[n_frames-1] - else: - if len(weights) == 0: - ann_list[bp[0], bp[1], "WCc"] += 1. - else: + dotbr = dotbr[:len(sequence)] + n_frames += 1 + base_pairs = parse_dotbr(dotbr) + for bp in base_pairs: + if bp not in list_base_pairs: + list_base_pairs.append(bp) + try: + ann_list[bp[0], bp[1], "WCc"] + except: + if len(weights) == 0: + ann_list[bp[0], bp[1], "WCc"] = 1. + else: + ann_list[bp[0], bp[1], "WCc"] = weights[n_frames-1] + else: + if len(weights) == 0: + ann_list[bp[0], bp[1], "WCc"] += 1. + else: ann_list[bp[0], bp[1], "WCc"] += weights[n_frames-1] if len(list_base_pairs) == 0: sys.exit("No basepairs found.") - if traj: - for ann, value in ann_list.items(): - if len(weights) == 0: - ann_list[ann] /= n_frames - else: - ann_list[ann] /= sum(weights) + for ann, value in ann_list.items(): + if len(weights) == 0: + ann_list[ann] /= n_frames + else: + ann_list[ann] /= sum(weights) chains = [0] return sequence, ann_list, list_base_pairs, n_frames diff --git a/bin/barnaba b/bin/barnaba index 066d37d..1c5de0f 100755 --- a/bin/barnaba +++ b/bin/barnaba @@ -316,15 +316,18 @@ def annotate(args): for i in range(len(args.pdbs)): st, pair, res = bb.annotate(args.pdbs[i]) stri_p += "# SEQ " + (" ".join([f for f in res]) + "\n") + stri_p += "# sequence %s\n" % "-".join(res) stri_p += "# PDB %s \n" % args.pdbs[i].split("/")[-1] stri_p += "".join([ "%-10s %-10s %4s \n" % (res[pair[0][0][e][0]],res[pair[0][0][e][1]],pair[0][1][e]) for e in range(len(pair[0][0]))]) + stri_s += "# sequence %s\n" % "-".join(res) stri_s += "# PDB %s \n" % args.pdbs[i].split("/")[-1] stri_s += "".join([ "%-10s %-10s %4s \n" % (res[st[0][0][e][0]],res[st[0][0][e][1]],st[0][1][e]) for e in range(len(st[0][0]))]) if(args.dotbr): dotbr,ss = bb.dot_bracket(pair,res) stri_dot += "# SEQ %s" % ss + stri_dot += "# sequence %s\n" % "-".join(res) stri_dot += "%-20s %s\n" %(args.pdbs[i].split("/")[-1],dotbr[0]) @@ -724,13 +727,13 @@ def sec_structure(args): output += "%8d%10.2e%10.2e%10.2e%10d\n" % (i, E, max_F, h, r_i) print( i, " steps of minmization") output += "%d steps of minmization\n" % (i) - from scipy.linalg import expm3, norm + from scipy.linalg import expm, norm av_stem_vector = np.mean([pos[int(param_stem[0][1])], pos[int(param_stem[0][2])]], axis=0) - np.mean([pos[int(param_stem[len(param_stem)-1][1])], pos[int(param_stem[len(param_stem)-1][2])]], axis=0) theta = np.arctan2(-av_stem_vector[0], -av_stem_vector[1]) def M(axis, theta): - return expm3(np.cross(np.eye(3), axis/norm(axis)*theta)) + return expm(np.cross(np.eye(3), axis/norm(axis)*theta)) axis = [0,0,1] m0 = M(axis, theta) trans_pos = np.full((len(pos),3), [dimensions*.5, dimensions*.5, 0])