File: AssemblyHelpers.cpp

package info (click to toggle)
pymol 2.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 43,312 kB
  • sloc: cpp: 480,106; python: 79,860; ansic: 28,343; javascript: 6,792; sh: 47; makefile: 30; csh: 8
file content (75 lines) | stat: -rw-r--r-- 1,694 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
 * Biological Assembly Helpers
 *
 * (c) 2017 Schrodinger, Inc.
 */

#include <vector>

#include "os_std.h"

#include "AssemblyHelpers.h"
#include "MemoryDebug.h"

/*
 * Create a coordset for a segi (chain) selection
 */
CoordSet * CoordSetCopyFilterChains(
    const CoordSet * other,
    const AtomInfoType * atInfo,
    const std::set<lexborrow_t> & chains_set)
{
  std::vector<int> idxmap;
  idxmap.reserve(other->NIndex);

  for (int idx = 0; idx < other->NIndex; ++idx)
    if (chains_set.count(atInfo[other->IdxToAtm[idx]].segi) > 0)
      idxmap.push_back(idx);

  CoordSet* cset = new CoordSet(other->G);

  cset->NIndex = idxmap.size();
  cset->Coord = pymol::vla<float>(cset->NIndex * 3);
  cset->IdxToAtm = pymol::vla<int>(cset->NIndex);
  cset->Obj = other->Obj;

  for (int idx = 0; idx < cset->NIndex; ++idx) {
    cset->IdxToAtm[idx] = other->IdxToAtm[idxmap[idx]];
    copy3f(other->coordPtr(idxmap[idx]), cset->coordPtr(idx));
  }

  return cset;
}

/*
 * Replace coordinate sets and set all_states
 */
void ObjectMoleculeSetAssemblyCSets(
    ObjectMolecule * I,
    CoordSet ** assembly_csets)
{
  if (!assembly_csets)
    return;

  if (I->DiscreteFlag) {
    printf("error/TODO: can't make discrete assembly\n");
    return;
  }

  // remove asymetric unit coordinate sets
  for (int i = 0; i < I->NCSet; ++i)
    if (I->CSet[i])
      I->CSet[i]->fFree();

  VLAFreeP(I->CSet);

  // get assembly coordinate sets into ObjectMolecule
  I->CSet = pymol::vla_take_ownership(assembly_csets);
  I->NCSet = VLAGetSize(assembly_csets);
  I->updateAtmToIdx();

  // all_states for multi-model assembly
  if (I->NCSet > 1) {
    SettingSet(cSetting_all_states, true, I);
  }
}