JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / src / MCview / Atom.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21 package MCview;
22
23 import java.awt.Color;
24
25 public class Atom
26 {
27   public float x;
28
29   public float y;
30
31   public float z;
32
33   public int number;
34
35   public String name;
36
37   public String resName;
38
39   public int resNumber;
40
41   public char insCode = ' ';
42
43   public String resNumIns = null;
44
45   public int type;
46
47   Color color = Color.lightGray;
48
49   public String chain;
50
51   /**
52    * this is a temporary value - designed to store the position in sequence that
53    * this atom corresponds to after aligning the chain to a SequenceI object. Do
54    * not rely on its value being correct when visualizing sequence colourings on
55    * the structure - use the StructureSelectionManager's mapping instead.
56    */
57   public int alignmentMapping = -1;
58
59   public int atomIndex;
60
61   public float occupancy = 0;
62
63   public float tfactor = 0;
64
65   // need these if we ever want to export Atom data
66   // public boolean tfacset=true,occset=true;
67   public boolean isSelected = false;
68
69   public Atom(String str)
70   {
71     atomIndex = Integer.parseInt(str.substring(6, 11).trim());
72
73     name = str.substring(12, 15).trim();
74
75     resName = str.substring(17, 20);
76
77     chain = str.substring(21, 22);
78
79     resNumber = Integer.parseInt(str.substring(22, 26).trim());
80     resNumIns = str.substring(22, 27).trim();
81     insCode = str.substring(26, 27).charAt(0);
82     this.x = (new Float(str.substring(30, 38).trim()).floatValue());
83     this.y = (new Float(str.substring(38, 46).trim()).floatValue());
84     this.z = (new Float(str.substring(47, 55).trim()).floatValue());
85     // optional entries - see JAL-730
86     String tm = str.substring(54, 60).trim();
87     if (tm.length() > 0)
88     {
89       occupancy = (new Float(tm)).floatValue();
90     }
91     else
92     {
93       occupancy = 1f; // default occupancy
94       // see note above: occset=false;
95     }
96     tm = str.substring(60, 66).trim();
97     if (tm.length() > 0)
98     {
99       tfactor = (new Float(tm).floatValue());
100     }
101     else
102     {
103       tfactor = 1f;
104       // see note above: tfacset=false;
105     }
106   }
107
108   public Atom(float x, float y, float z)
109   {
110     this.x = x;
111     this.y = y;
112     this.z = z;
113   }
114 }