@@ 854-910 (lines=57) @@ | ||
851 | color_by_text(txt) |
|
852 | ||
853 | ||
854 | def color_obj(rainbow=0): |
|
855 | ||
856 | """ |
|
857 | stolen from :) |
|
858 | AUTHOR |
|
859 | Gareth Stockwell |
|
860 | ||
861 | USAGE |
|
862 | color_obj(rainbow=0) |
|
863 | ||
864 | This function colours each object currently in the PyMOL heirarchy |
|
865 | with a different colour. Colours used are either the 22 named |
|
866 | colours used by PyMOL (in which case the 23rd object, if it exists, |
|
867 | gets the same colour as the first), or are the colours of the rainbow |
|
868 | ||
869 | """ |
|
870 | ||
871 | # Process arguments |
|
872 | rainbow = int(rainbow) |
|
873 | ||
874 | # Get names of all PyMOL objects |
|
875 | obj_list = cmd.get_names('objects') |
|
876 | ||
877 | if rainbow: |
|
878 | ||
879 | print("\nColouring objects as rainbow\n") |
|
880 | ||
881 | nobj = len(obj_list) |
|
882 | ||
883 | # Create colours starting at blue(240) to red(0), using intervals |
|
884 | # of 240/(nobj-1) |
|
885 | for j in range(nobj): |
|
886 | hsv = (240-j*240/(nobj-1), 1, 1) |
|
887 | # Convert to RGB |
|
888 | rgb = hsv_to_rgb(hsv) |
|
889 | # Define the new colour |
|
890 | cmd.set_color("col" + str(j), rgb) |
|
891 | print(obj_list[j], rgb) |
|
892 | # Colour the object |
|
893 | cmd.color("col" + str(j), obj_list[j]) |
|
894 | ||
895 | else: |
|
896 | # List of available colours |
|
897 | colours = ['red', 'green', 'blue', 'yellow', 'violet', 'cyan', \ |
|
898 | 'salmon', 'lime', 'pink', 'slate', 'magenta', 'orange', 'marine', \ |
|
899 | 'olive', 'purple', 'teal', 'forest', 'firebrick', 'chocolate', \ |
|
900 | 'wheat', 'white', 'grey' ] |
|
901 | ncolours = len(colours) |
|
902 | ||
903 | # Loop over objects |
|
904 | i = 0 |
|
905 | for obj in obj_list: |
|
906 | print(" ", obj, colours[i]) |
|
907 | cmd.color(colours[i], obj) |
|
908 | i = i+1 |
|
909 | if(i == ncolours): |
|
910 | i = 0 |
|
911 | ||
912 | ||
913 | def names(): |
|
@@ 920-958 (lines=39) @@ | ||
917 | print(o) |
|
918 | ||
919 | ||
920 | def color_rbw(rainbow=0): |
|
921 | """ |
|
922 | similar to color_obj() but this time colors every obect as rainbow |
|
923 | """ |
|
924 | rainbow = int(rainbow) |
|
925 | ||
926 | # Get names of all PyMOL objects |
|
927 | obj_list = cmd.get_names('objects') |
|
928 | ||
929 | if rainbow: |
|
930 | ||
931 | print("\nColouring objects as rainbow\n") |
|
932 | ||
933 | nobj = len(obj_list) |
|
934 | ||
935 | # Create colours starting at blue(240) to red(0), using intervals |
|
936 | # of 240/(nobj-1) |
|
937 | for j in range(nobj): |
|
938 | hsv = (240-j*240/(nobj-1), 1, 1) |
|
939 | # Convert to RGB |
|
940 | rgb = hsv_to_rgb(hsv) |
|
941 | # Define the new colour |
|
942 | cmd.set_color("col" + str(j), rgb) |
|
943 | print(obj_list[j], rgb) |
|
944 | # Colour the object |
|
945 | cmd.color("col" + str(j), obj_list[j]) |
|
946 | else: |
|
947 | colours = ['rainbow'] |
|
948 | ncolours = len(colours) |
|
949 | ||
950 | # Loop over objects |
|
951 | i = 0 |
|
952 | for obj in obj_list: |
|
953 | print(" ", obj, colours[i]) |
|
954 | cmd.spectrum('count', colours[i], obj) |
|
955 | # cmd.color(colours[i], obj) |
|
956 | i = i+1 |
|
957 | if(i == ncolours): |
|
958 | i = 0 |
|
959 | ||
960 | ||
961 | def strip_selection_name(selection_name): |