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 package ffx.ui.commands;
39
40 import ffx.potential.MolecularAssembly;
41 import ffx.potential.Utilities.FileType;
42 import ffx.potential.bonded.Atom;
43 import ffx.potential.bonded.Bond;
44 import ffx.potential.parameters.AtomType;
45 import ffx.potential.parsers.SystemFilter;
46 import java.io.File;
47 import java.util.ArrayList;
48 import java.util.Hashtable;
49 import java.util.Vector;
50
51
52
53
54
55
56 public final class SimulationFilter extends SystemFilter {
57
58 SimulationDefinition system;
59 Hashtable<Integer, AtomType> atomTypes = new Hashtable<Integer, AtomType>();
60
61
62
63
64
65
66
67 public SimulationFilter(SimulationDefinition sys, MolecularAssembly m) {
68 super(new File(""), m, null, null);
69 system = sys;
70 fileType = FileType.SIM;
71 fileRead = false;
72 }
73
74 @Override
75 public void closeReader() {
76
77
78 }
79
80
81 @Override
82 public boolean readFile() {
83
84
85 for (int i = 0; i < system.numatoms; i++) {
86 AtomType atomType = atomTypes.get(system.types[i]);
87 if (atomType == null) {
88 atomType =
89 new AtomType(
90 system.types[i],
91 -1,
92 system.name[i],
93 system.story[i],
94 system.atomic[i],
95 system.mass[i],
96 0);
97 atomTypes.put(system.types[i], atomType);
98 }
99 }
100 atomList = new ArrayList<Atom>();
101 Vector<Integer> bonds1 = new Vector<Integer>();
102 Vector<Integer> bonds2 = new Vector<Integer>();
103 double[] d = new double[3];
104 int[] b = new int[4];
105 for (int i = 0; i < system.numatoms; i++) {
106 d[0] = system.coordinates[0][i];
107 d[1] = system.coordinates[1][i];
108 d[2] = system.coordinates[2][i];
109 String s = "" + system.types[i];
110 AtomType atomType = atomTypes.get(s);
111 Atom a = new Atom(i + 1, "" + atomType.type, atomType, d);
112 atomList.add(a);
113 int b1 = i + 1;
114 b[0] = system.connectivity[0][i];
115 b[1] = system.connectivity[1][i];
116 b[2] = system.connectivity[2][i];
117 b[3] = system.connectivity[3][i];
118 int j = 0;
119 while (j < 4 && b[j] != 0) {
120 int b2 = b[j];
121 bonds1.add(b1);
122 bonds2.add(b2);
123 j++;
124 }
125 }
126 bondList = new ArrayList<Bond>();
127 for (int i = 0; i < bonds1.size(); i++) {
128 int a1 = bonds1.get(i);
129 int a2 = bonds2.get(i);
130 if (a1 < a2) {
131 Atom atom1 = atomList.get(a1 - 1);
132 Atom atom2 = atomList.get(a2 - 1);
133 bondList.add(new Bond(atom1, atom2));
134 }
135 }
136 setFileRead(true);
137 return true;
138 }
139
140 @Override
141 public boolean readNext(boolean resetPosition) {
142 return false;
143 }
144
145 @Override
146 public boolean readNext(boolean resetPosition, boolean print) {
147 return false;
148 }
149
150 @Override
151 public boolean readNext(boolean resetPosition, boolean print, boolean parse) {
152 return false;
153 }
154
155 @Override
156 public boolean readNext() {
157 return readNext(false);
158 }
159
160
161 @Override
162 public boolean writeFile(File saveFile, boolean append, String[] extraLines) {
163 return false;
164 }
165 }