diff --git a/modevectors.py b/modevectors.py index c85ef3d8..8d5faba4 100644 --- a/modevectors.py +++ b/modevectors.py @@ -1,6 +1,7 @@ ''' See more here: http://www.pymolwiki.org/index.php/Modevectors ''' +from __future__ import print_function from pymol.cgo import * # get constants from math import * from pymol import cmd @@ -37,7 +38,7 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou factor 1.0 Float Multiplies each mode vector length by a specified factor. Values between 0 and 1 will decrease the relative mode vector length. Values greater than 1 will increase the relative mode vector length. - notail 0 Integer Hides tails and only uses cones (porcupine plot) + notail 0 Integer Hides tails and only uses cones (porcupine plot) """ framefirst = cmd.get_model(first_obj_frame, first_state) @@ -55,8 +56,8 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou headrgb = headrgb.strip('" []()') tailrgb = tailrgb.strip('" []()') - hr, hg, hb = map(float, headrgb.split(',')) - tr, tg, tb = map(float, tailrgb.split(',')) + hr, hg, hb = list(map(float, headrgb.split(','))) + tr, tg, tb = list(map(float, tailrgb.split(','))) version = cmd.get_version()[1] arrow = [] @@ -138,10 +139,10 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou " ATMNUM " + str(atom.index) # print current_atom if 'current_atom' not in atom_lookup: - print "\nError: " + current_atom + " from \""\ + print("\nError: " + current_atom + " from \""\ + last_obj_frame +\ - " \"is not found in \"" + first_obj_frame + "\"." - print "\nPlease check your input and/or selections and try again." + " \"is not found in \"" + first_obj_frame + "\".") + print("\nPlease check your input and/or selections and try again.") exit_flag = True break @@ -168,10 +169,10 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou ################################################### if len(x2) != len(x1): - print "\nError: \"" + first_obj_frame +\ + print("\nError: \"" + first_obj_frame +\ "\" and \"" + last_obj_frame +\ - "\" contain different number of residue/atoms." - print "\nPlease check your input and/or selections and try again." + "\" contain different number of residue/atoms.") + print("\nPlease check your input and/or selections and try again.") return else: # Continue with representing modevectors! @@ -232,7 +233,7 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou intfactor = int(factor) if version < 1.1: # Version >= 1.1 has cone primitive for i in range(100, 0, -1): # i=100 is tip of cone - print i + print(i) t1 = seg * i t2 = seg * (i + 1) radius = arrow_head_radius * (1.0 - i / (100.0)) # Radius of each disc that forms cone @@ -257,13 +258,13 @@ def modevectors(first_obj_frame, last_obj_frame, first_state=1, last_state=1, ou if stat == "show": natoms = skipcounter + keepcounter - print "\nTotal number of atoms = " + str(natoms) - print "Atoms skipped = " + str(skipcounter) + print("\nTotal number of atoms = " + str(natoms)) + print("Atoms skipped = " + str(skipcounter)) if keepcounter - cutoff_counter > 0: - print "Atoms counted = " + str(keepcounter - cutoff_counter) + " (see PyMOL object \"" + objectname + "\")" + print("Atoms counted = " + str(keepcounter - cutoff_counter) + " (see PyMOL object \"" + objectname + "\")") else: - print "Atoms counted = " + str(keepcounter - cutoff_counter) + " (Empty CGO object not loaded)" - print "Atoms cutoff = " + str(cutoff_counter) # Note that cutoff occurs AFTER skipping! + print("Atoms counted = " + str(keepcounter - cutoff_counter) + " (Empty CGO object not loaded)") + print("Atoms cutoff = " + str(cutoff_counter)) # Note that cutoff occurs AFTER skipping! if keepcounter - cutoff_counter > 0: cmd.delete(objectname) cmd.load_cgo(arrow, objectname) # Ray tracing an empty object will cause a segmentation fault. No arrows = Do not display in PyMOL!!! diff --git a/movie_color_fade.py b/movie_color_fade.py index 97ac2828..6b93ac5a 100644 --- a/movie_color_fade.py +++ b/movie_color_fade.py @@ -16,6 +16,7 @@ ''' #------------------------------------------------------------------------------- # IMPORT +from __future__ import print_function from pymol import cmd from pymol import stored #------------------------------------------------------------------------------- @@ -72,7 +73,7 @@ def movie_color_fade( movie_color_fade auto,white,auto,skyblue,ss s movie_color_fade auto,white,auto,red,ss h movie_color_fade auto,white,auto,grey,ss l+"" - ##### + ##### SEE ALSO @@ -93,7 +94,7 @@ def movie_color_fade( endframe = 1 if startframe == endframe: - print "start == end" + print("start == end") return False if startframe > endframe: @@ -106,14 +107,14 @@ def movie_color_fade( endcolor = cmd.get_color_tuple(endcolor) diffcolor = [b - a for a, b in zip(startcolor, endcolor)] except: - print "Input error - please provide regular colors" + print("Input error - please provide regular colors") return False for frame in range(startframe, endframe + 1): # calculate intermediates frac = float(frame - startframe) / (endframe - startframe) endcolor = [a * frac for a in diffcolor] - endcolor = map(sum, zip(startcolor, endcolor)) + endcolor = list(map(sum, list(zip(startcolor, endcolor)))) colorname = selection + "_" + str(frame) # define new color cmd.set_color(colorname, endcolor) diff --git a/nmr_cnstr.py b/nmr_cnstr.py index fbdd1f24..dbeb8f47 100644 --- a/nmr_cnstr.py +++ b/nmr_cnstr.py @@ -17,6 +17,7 @@ ############################################################################################################## ''' +from __future__ import print_function def upl(fname): @@ -26,7 +27,7 @@ def upl(fname): # while upl != '': - print upl, i + print(upl, i) cns = string.split(upl) cmd.dist('upl' + str(i), 'i. ' + cns[0] + ' & n. ' + cns[2], 'i. ' + cns[3] + ' & n. ' + cns[5]) upl = f.readline() @@ -44,21 +45,21 @@ def cns(fname): f = open(fname, 'r') i = 1 upl = f.readline() - print upl, i + print(upl, i) while upl != '': if upl == '\n': upl = f.readline() continue cns = string.split(upl) - print cns, i + print(cns, i) if cns[0] == 'assign': - print 'CNS' + print('CNS') if cns[5] == 'HB*': - print 'CNS***' + print('CNS***') cmd.dist('upl' + str(i), 'i. ' + cns[2] + ' & n. ' + cns[5], 'i. ' + cns[7] + ' & n. ' + cns[10]) i += 1 upl = f.readline() - print '*' + upl + '*', i + print('*' + upl + '*', i) f.close() cmd.set('dash_gap', 0.05)