@@ -26,40 +26,56 @@ document.addEventListener( "DOMContentLoaded", function() {
2626 stage .setParameters ({ backgroundColor: " white" } );
2727
2828 // Parse TSV file
29- // This can be cleaner
30- raw_lines = tsv .split (" \n " );
31- var lines = []
32- for (k = 0 ; k < raw_lines .length ; k++ ) {
33- if (! raw_lines[k].startsWith (" #" ) && raw_lines[k].length > 0 ) {
34- lines .push (raw_lines[k])
35- }
36- }
29+ // Each line should contain ResNum/Chain/AminoAcid triplets
30+ // Lines end with tabs, so each line should have 3n+1 columns for n repeats.
31+ var lines = tsv .split (" \n " )
32+ .filter ((x ) => ! x .startsWith (" #" ) && x .length > 0 )
33+ .map ((x ) => x .split (" \t " ));
3734
3835 // Get number of structures from first line
39- var n_strucs = (lines[0 ].split ( " \t " ). length - 1 ) / 3 ;
36+ var n_strucs = (lines[0 ].length - 1 ) / 3 ;
4037
4138 // Generate color palette
4239 var colors = palette (' cb-Dark2' , n_strucs);
4340
44- stage .loadFile ( " /pdb/{{structureId}}" , { defaultRepresentation: false , ext: " pdb" } ).then ( function ( o ){
45- o .addRepresentation ( " backbone" , { color: " lightgrey" } );
41+ // Create selection for each repeat
42+ var colorSele = [];
43+ for (j = 0 ; j < n_strucs; j++ ) {
44+ var seleStr = [];
4645 for (i = 0 ; i < lines .length ; i++ ) {
47- var tabs = lines[i].split (" \t " );
48- for (j = 0 ; j < n_strucs; j++ ) {
49- if (tabs[3 * j] != " -" ) {
50- o .addRepresentation ( " backbone" , {
51- sele: " (" + tabs[3 * j] + " or " + (parseInt (tabs[3 * j])+ 1 ) + " ) and :" + tabs[3 * j+ 1 ],
52- color: " #" + colors[j]
53- });
54- }
46+ if (lines[i][3 * j] != " -" ) {
47+ seleStr .push (" ( " + lines[i][3 * j] + " and :" + lines[i][3 * j+ 1 ] + " )" );
5548 }
5649 }
50+ colorSele .push ( [" #" + colors[j], seleStr .join (" or " )]);
51+ }
52+ colorSele .push ([" lightgrey" ," *" ]);
53+ console .log (colorSele);
54+
55+ var schemeId = NGL .ColorMakerRegistry .addSelectionScheme ( colorSele, " CE-Symm {{structureId}}" );
56+
57+
58+ stage .loadFile ( " /pdb/{{structureId}}" , { defaultRepresentation: false , ext: " pdb" } ).then ( function ( o ){
59+ o .addRepresentation ( " cartoon" , { color: schemeId } );
5760 o .addRepresentation ( " ball+stick" , {
5861 sele: " hetero and not ( water )"
5962 });
6063 o .centerView ();
6164 } );
62- });
65+
66+ /* var schemeId = NGL.ColorMakerRegistry.addSelectionScheme( [
67+ [ "red", "64-74 or 134-154 or 222-254 or 310-310 or 322-326" ],
68+ [ "green", "311-322" ],
69+ [ "yellow", "40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309" ],
70+ [ "blue", "1-39 or 96-112 or 174-201 or 278-288" ],
71+ [ "white", "*" ]
72+ ], "Transmembrane 3dqb" );
73+
74+ stage.loadFile( "rcsb://3dqb.pdb" ).then( function( o ){
75+ o.addRepresentation( "cartoon", { color: schemeId } ); // pass schemeId here
76+ o.centerView();
77+ } );
78+ */ });
6379} );
6480
6581</script >
0 commit comments