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