-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalysisThread.java
74 lines (59 loc) · 2.38 KB
/
AnalysisThread.java
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
import utils.ScoreUtilities.ScoringGeneralHelpers;
import utils.Scoring.MRC_Score;
import utils.molecularElements.AminoAcid;
import utils.molecularElements.SimpleAtom;
import utils.molecularElements.SimpleProtein;
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.Callable;
/**
* Created by zivben on 11/12/16.
*/
public class AnalysisThread implements Callable<HashMap<Character,HashMap<String,List<Double[]>>>> {
private final String[] args;
public AnalysisThread(String[] tempArgs) {
this.args = tempArgs;
}
@Override
public HashMap<Character,HashMap<String,List<Double[]>>> call() throws Exception{
HashMap<Character,HashMap<String,List<Double[]>>> resultMap = new HashMap<>();
for (char aAcid : ScoringGeneralHelpers.singleLetters){
resultMap.put(aAcid, new HashMap<String,List<Double[]>>());
}
MRC_Score myScore = null;
try {
// if argument string does not include chain to process, then entire protein needs to be processed (not used).
if (args.length == 2) {
myScore = new MRC_Score(args[1], args[0]);
char[] chains = myScore.getMyProt().getChains();
for (char chain : chains) {
myScore = new MRC_Score(myScore.getMyProt(), String.valueOf(chain), myScore.getMyMap());
SimpleProtein.ProtChain workingChaing = myScore.getMyProt().getChain(chain);
for (AminoAcid acid : workingChaing){
float[] alphaCoords = acid.getCalpha().getAtomCoords();
double cAlphaScore = myScore.getMyMap().val(alphaCoords[0],alphaCoords[1],alphaCoords[2]);
for (SimpleAtom atom : acid){
float[] coords = atom.getAtomCoords();
try {
atom.setAtomScore(myScore.getMyMap().val(coords[0], coords[1], coords[2]));
} catch (RuntimeException e) {
atom.setAtomScore(0.0);
}
if (!resultMap.get(acid.getSingleLetter()).containsKey(atom.getName())){
resultMap.get(acid.getSingleLetter()).put(atom.getName(),new LinkedList<Double[]>());
resultMap.get(acid.getSingleLetter()).get(atom.getName()).add(new Double[]{cAlphaScore, atom.getAtomScore()});
} else{
resultMap.get(acid.getSingleLetter()).get(atom.getName()).add(new Double[]{cAlphaScore, atom.getAtomScore()});
}
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
return resultMap;
}
}