ソースを参照

Merge pull request #2 from yakomaxa/PyMOL

added all and polymer.protein to keywords of pymol
KoyaS 2 年 前
コミット
f532325147
1 ファイル変更82 行追加5 行削除
  1. 82 5
      src/mol-script/transpilers/pymol/keywords.ts

+ 82 - 5
src/mol-script/transpilers/pymol/keywords.ts

@@ -16,11 +16,17 @@ const ResDict = {
     solvent: ['HOH', 'WAT', 'H20', 'TIP', 'SOL']
 };
 
+const Backbone = {
+    nucleic: ['P', "O3'", "O5'", "C5'", "C4'", "C3'", 'OP1', 'OP2', 'O3*', 'O5*', 'C5*', 'C4*', 'C3*'],
+    protein: ['C', 'N', 'CA', 'O']
+};
+
+
 export const keywords: KeywordDict = {
     all: {
         '@desc': 'All atoms currently loaded into PyMOL',
         abbr: ['*'],
-        map: () => B.struct.generator.atomGroups()
+        map: () => B.struct.generator.all()
     },
     none: {
         '@desc': 'No atoms (empty selection)',
@@ -57,10 +63,6 @@ export const keywords: KeywordDict = {
             ])
         })
     },
-    backbone: {
-        '@desc': 'Polymer backbone atoms (new in PyMOL 1.6.1)',
-        abbr: ['bb.']
-    },
     sidechain: {
         '@desc': 'Polymer non-backbone atoms (new in PyMOL 1.6.1)',
         abbr: ['sc.']
@@ -198,5 +200,80 @@ export const keywords: KeywordDict = {
     },
     metals: {
         '@desc': 'All metal atoms (new in PyMOL 1.6.1)'
+    },
+    backbone: {
+        '@desc': 'the C, N, CA, and O atoms of a protein and the equivalent atoms in a nucleic acid.',
+        map: () => backboneExpr()
+    },
+    protein: {
+        '@desc': 'protein',
+	abbr: ['polymer.protein'],
+        map: () => B.struct.generator.atomGroups({
+            'residue-test': B.core.set.has([
+                B.core.type.set(ResDict.protein),
+                B.ammp('label_comp_id')
+            ])
+        })
     }
 };
+
+function backboneExpr() {
+    return B.struct.combinator.merge([
+        B.struct.generator.queryInSelection({
+            0: proteinExpr(),
+            query: B.struct.generator.atomGroups({
+                'atom-test': B.core.set.has([
+                    h.atomNameSet(Backbone.protein),
+                    B.ammp('label_atom_id')
+                ])
+            })
+        }),
+        B.struct.generator.queryInSelection({
+            0: nucleicExpr(),
+            query: B.struct.generator.atomGroups({
+                'atom-test': B.core.set.has([
+                    h.atomNameSet(Backbone.nucleic),
+                    B.ammp('label_atom_id')
+                ])
+            })
+        })
+    ]);
+}
+
+function proteinExpr() {
+    return B.struct.filter.pick({
+        0: B.struct.generator.atomGroups({
+            'group-by': B.ammp('residueKey')
+        }),
+        test: B.core.set.isSubset([
+            h.atomNameSet(['C', 'N', 'CA', 'O']),
+            B.ammpSet('label_atom_id')
+        ])
+    });
+}
+
+function nucleicExpr() {
+    return B.struct.filter.pick({
+        0: B.struct.generator.atomGroups({
+            'group-by': B.ammp('residueKey')
+        }),
+        test: B.core.logic.and([
+            B.core.set.isSubset([
+                // B.core.type.set([ 'P', 'O1P', 'O2P' ]),
+                h.atomNameSet(['P']),
+                B.ammpSet('label_atom_id')
+            ]),
+            B.core.logic.or([
+                B.core.set.isSubset([
+                    h.atomNameSet(["O3'", "C3'", "C4'", "C5'", "O5'"]),
+                    B.ammpSet('label_atom_id')
+                ]),
+                B.core.set.isSubset([
+                    h.atomNameSet(['O3*', 'C3*', 'C4*', 'C5*', 'O5*']),
+                    B.ammpSet('label_atom_id')
+                ])
+            ])
+        ])
+    });
+}
+