70 |
|
pdbresser2resser.put(String.valueOf(resser), resser); |
71 |
|
} |
72 |
|
|
73 |
+ |
// initialising atomser2atom from resser_atom2atomserial |
74 |
+ |
atomser2atom = new HashMap<Integer, String>(); |
75 |
+ |
for (String resser_atom:resser_atom2atomserial.keySet()){ |
76 |
+ |
int atomserial = resser_atom2atomserial.get(resser_atom); |
77 |
+ |
String atom = resser_atom.split("_")[1]; |
78 |
+ |
atomser2atom.put(atomserial,atom); |
79 |
+ |
} |
80 |
|
} |
81 |
|
|
82 |
|
|
99 |
|
resser2restype = new HashMap<Integer,String>(); |
100 |
|
atomser2coord = new HashMap<Integer,Point3d>(); |
101 |
|
atomser2resser = new HashMap<Integer,Integer>(); |
102 |
+ |
Pattern p; |
103 |
+ |
Matcher m; |
104 |
|
boolean empty = true; // controls whether we don't find any atom line for given pdbChainCode and model |
105 |
|
// we set chainCodeStr (for regex) to pdbChainCode except for case NULL where we use " " (NULL is a blank chain code in pdb files) |
106 |
|
String chainCodeStr=pdbChainCode; |
110 |
|
BufferedReader fpdb = new BufferedReader(new FileReader(new File(pdbfile))); |
111 |
|
int linecount=0; |
112 |
|
String line; |
113 |
< |
while ((line = fpdb.readLine() ) != null ) { |
114 |
< |
linecount++; |
113 |
> |
// read first line |
114 |
> |
if((line = fpdb.readLine()) != null ) { |
115 |
> |
linecount = 1; |
116 |
|
// HEADER |
117 |
< |
Pattern p = Pattern.compile("^HEADER"); |
118 |
< |
Matcher m = p.matcher(line); |
117 |
> |
p = Pattern.compile("^HEADER"); |
118 |
> |
m = p.matcher(line); |
119 |
|
if (m.find()){ |
120 |
|
Pattern ph = Pattern.compile("^HEADER.{56}(\\d\\w{3})"); |
121 |
|
Matcher mh = ph.matcher(line); |
122 |
|
if (mh.find()) { |
123 |
|
pdbCode=mh.group(1).toLowerCase(); |
124 |
|
} |
125 |
< |
} else if (linecount==1) { // header not found and we are in line 1 |
126 |
< |
// a HEADER is the minimum we ask at the moment for a pdb file to have, if we don't find it in line 1 we throw an exception |
127 |
< |
throw new PdbfileFormatError("The pdb file "+pdbfile+" doesn't seem to have the right format"); |
125 |
> |
} else { // header not found |
126 |
> |
// check whether this is a Casp prediction file |
127 |
> |
p = Pattern.compile("^PFRMAT TS"); |
128 |
> |
m = p.matcher(line); |
129 |
> |
if(m.find()) { |
130 |
> |
// ok, it is |
131 |
> |
pdbCode = "CASP"; |
132 |
> |
} else { |
133 |
> |
// a HEADER is the minimum we ask at the moment for a pdb file to have, if we don't find it in line 1 we throw an exception |
134 |
> |
throw new PdbfileFormatError("The pdb file "+pdbfile+" doesn't seem to have the right format"); |
135 |
> |
} |
136 |
|
} |
137 |
+ |
} else { |
138 |
+ |
throw new PdbfileFormatError("The file "+pdbfile+" is empty."); |
139 |
+ |
} |
140 |
+ |
// read further lines |
141 |
+ |
while ((line = fpdb.readLine() ) != null ) { |
142 |
+ |
linecount++; |
143 |
|
// SECONDARY STRUCTURE |
144 |
|
// helix |
145 |
|
//HELIX 1 1 LYS A 17 LEU A 26 1 |
154 |
|
secstruct2resinterval.put(ssId, new Interval(beg,end)); |
155 |
|
for (int i=beg;i<=end;i++){ |
156 |
|
if (resser2secstruct.containsKey(i)){// if already assigned we print a warning and then assign it |
157 |
< |
System.err.println("Inconsistency in secondary structure assignment. " + |
158 |
< |
"Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
157 |
> |
//System.err.println("Inconsistency in secondary structure assignment. " + |
158 |
> |
// "Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
159 |
|
} |
160 |
|
resser2secstruct.put(i,ssId); |
161 |
|
} |
174 |
|
secstruct2resinterval.put(ssId, new Interval(beg,end)); |
175 |
|
for (int i=beg;i<=end;i++){ |
176 |
|
if (resser2secstruct.containsKey(i)){// if already assigned we print a warning and then assign it |
177 |
< |
System.err.println("Inconsistency in secondary structure assignment. " + |
178 |
< |
"Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
177 |
> |
//System.err.println("Inconsistency in secondary structure assignment. " + |
178 |
> |
// "Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
179 |
|
} |
180 |
|
resser2secstruct.put(i,ssId); |
181 |
|
} |
195 |
|
secstruct2resinterval.put(ssId, new Interval(beg,end)); |
196 |
|
for (int i=beg;i<=end;i++){ |
197 |
|
if (resser2secstruct.containsKey(i)){// if already assigned we print a warning and then assign it |
198 |
< |
System.err.println("Inconsistency in secondary structure assignment. " + |
199 |
< |
"Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
198 |
> |
//System.err.println("Inconsistency in secondary structure assignment. " + |
199 |
> |
// "Residue "+i+" is getting reassigned from "+resser2secstruct.get(i)+" to "+ssId); |
200 |
|
} |
201 |
|
resser2secstruct.put(i,ssId); |
202 |
|
} |