| 1 |
|
package jalview.bin.argparser; |
| 2 |
|
|
| 3 |
|
import java.io.File; |
| 4 |
|
import java.util.ArrayList; |
| 5 |
|
import java.util.List; |
| 6 |
|
|
| 7 |
|
import jalview.bin.Cache; |
| 8 |
|
import jalview.bin.Console; |
| 9 |
|
import jalview.datamodel.AlignmentI; |
| 10 |
|
import jalview.datamodel.PDBEntry; |
| 11 |
|
import jalview.datamodel.SequenceI; |
| 12 |
|
import jalview.gui.AssociatePdbFileWithSeq; |
| 13 |
|
import jalview.gui.Desktop; |
| 14 |
|
import jalview.gui.StructureChooser; |
| 15 |
|
import jalview.gui.StructureViewer.ViewerType; |
| 16 |
|
import jalview.io.AppletFormatAdapter; |
| 17 |
|
import jalview.io.DataSourceType; |
| 18 |
|
|
| |
|
| 87.6% |
Uncovered Elements: 11 (89) |
Complexity: 24 |
Complexity Density: 0.44 |
|
| 19 |
|
public class StructuresFile |
| 20 |
|
{ |
| 21 |
|
private boolean superpose = Cache |
| 22 |
|
.getDefault(StructureChooser.AUTOSUPERIMPOSE, true); |
| 23 |
|
|
| 24 |
|
private String viewerid = null; |
| 25 |
|
|
| 26 |
|
private ViewerType viewerType = ViewerType.JMOL; |
| 27 |
|
|
| 28 |
|
private List<StructureLine> structureLines; |
| 29 |
|
|
| 30 |
|
private List<SequenceI> seqs = new ArrayList<>(); |
| 31 |
|
|
| 32 |
|
private List<PDBEntry> pdbs = new ArrayList<>(); |
| 33 |
|
|
| 34 |
|
private AlignmentI alignment; |
| 35 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 36 |
5 |
public StructuresFile(AlignmentI al, String filename)... |
| 37 |
|
{ |
| 38 |
5 |
alignment = al; |
| 39 |
5 |
setStructureLines(parseStructuresFile(new File(filename))); |
| 40 |
|
} |
| 41 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
5 |
public boolean isSuperpose()... |
| 43 |
|
{ |
| 44 |
5 |
return superpose; |
| 45 |
|
} |
| 46 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 47 |
5 |
public void setSuperpose(boolean superpose)... |
| 48 |
|
{ |
| 49 |
5 |
this.superpose = superpose; |
| 50 |
|
} |
| 51 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
20 |
public String getViewerid()... |
| 53 |
|
{ |
| 54 |
20 |
return viewerid; |
| 55 |
|
} |
| 56 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
5 |
public void setViewerid(String viewerid)... |
| 58 |
|
{ |
| 59 |
5 |
this.viewerid = viewerid; |
| 60 |
|
} |
| 61 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 62 |
5 |
public ViewerType getViewerType()... |
| 63 |
|
{ |
| 64 |
5 |
return viewerType; |
| 65 |
|
} |
| 66 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 67 |
5 |
public void setViewerType(ViewerType viewerType)... |
| 68 |
|
{ |
| 69 |
5 |
this.viewerType = viewerType; |
| 70 |
|
} |
| 71 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 72 |
0 |
public List<StructureLine> getStructureLines()... |
| 73 |
|
{ |
| 74 |
0 |
return structureLines; |
| 75 |
|
} |
| 76 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 77 |
5 |
public void setStructureLines(List<StructureLine> structureLines)... |
| 78 |
|
{ |
| 79 |
5 |
this.structureLines = structureLines; |
| 80 |
|
} |
| 81 |
|
|
| |
|
| 84.8% |
Uncovered Elements: 7 (46) |
Complexity: 8 |
Complexity Density: 0.25 |
|
| 82 |
5 |
public List<StructureLine> parseStructuresFile(File structuresFile)... |
| 83 |
|
{ |
| 84 |
5 |
if (!structuresFile.exists()) |
| 85 |
|
{ |
| 86 |
0 |
String message = Arg.STRUCTURESFILE.argString() + ArgParser.EQUALS |
| 87 |
|
+ "\"" + structuresFile.getPath() |
| 88 |
|
+ "\": File does not exist."; |
| 89 |
0 |
Console.warn(message); |
| 90 |
0 |
return null; |
| 91 |
|
} |
| 92 |
5 |
List<String> lines = ArgParser.readArgFile(structuresFile); |
| 93 |
5 |
List<StructureLine> structurelines = new ArrayList<>(); |
| 94 |
5 |
if (lines != null) |
| 95 |
|
{ |
| 96 |
5 |
for (String line : lines) |
| 97 |
|
{ |
| 98 |
28 |
if (line.startsWith(ArgParser.DOUBLEDASH)) |
| 99 |
|
{ |
| 100 |
13 |
String val = getArgVal(Arg.VIEWERID, line); |
| 101 |
13 |
if (val != null) |
| 102 |
|
{ |
| 103 |
3 |
setViewerid(val); |
| 104 |
3 |
continue; |
| 105 |
|
} |
| 106 |
10 |
val = getArgVal(Arg.STRUCTUREVIEWER, line); |
| 107 |
10 |
if (val != null) |
| 108 |
|
{ |
| 109 |
5 |
setViewerType(ViewerType.getFromString(val)); |
| 110 |
5 |
continue; |
| 111 |
|
} |
| 112 |
5 |
Boolean b = getArgBoolean(Arg.SUPERPOSE, line); |
| 113 |
5 |
if (b != null) |
| 114 |
|
{ |
| 115 |
5 |
setSuperpose(b); |
| 116 |
5 |
continue; |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
15 |
StructureLine sl = new StructureLine(line); |
| 120 |
15 |
structurelines.add(sl); |
| 121 |
15 |
String structureLocationRef = sl.getSource(); |
| 122 |
15 |
DataSourceType structureLocationType = AppletFormatAdapter |
| 123 |
|
.checkProtocol(structureLocationRef); |
| 124 |
15 |
if (DataSourceType.FILE.equals(structureLocationType)) |
| 125 |
|
{ |
| 126 |
15 |
structureLocationRef = new File(structureLocationRef) |
| 127 |
|
.getAbsolutePath(); |
| 128 |
|
} |
| 129 |
15 |
SequenceI seq = alignment.findName(sl.getSeqid()); |
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
15 |
PDBEntry pdbEntry = AssociatePdbFileWithSeq |
| 134 |
|
.associatePdbWithSeq(structureLocationRef, |
| 135 |
|
structureLocationType, seq, false, Desktop.getInstance(), |
| 136 |
|
null, null, false); |
| 137 |
|
|
| 138 |
15 |
pdbs.add(pdbEntry); |
| 139 |
15 |
seqs.add(seq); |
| 140 |
|
|
| 141 |
|
} |
| 142 |
|
} |
| 143 |
5 |
return structurelines; |
| 144 |
|
} |
| 145 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 146 |
10 |
public SequenceI[] getSeqs()... |
| 147 |
|
{ |
| 148 |
10 |
SequenceI[] array = new SequenceI[seqs.size()]; |
| 149 |
10 |
return seqs.toArray(array); |
| 150 |
|
} |
| 151 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 152 |
5 |
public PDBEntry[] getPdbEntries()... |
| 153 |
|
{ |
| 154 |
5 |
PDBEntry[] array = new PDBEntry[pdbs.size()]; |
| 155 |
5 |
return pdbs.toArray(array); |
| 156 |
|
} |
| 157 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 158 |
23 |
private static String getArgVal(Arg a, String line)... |
| 159 |
|
{ |
| 160 |
23 |
String s = new StringBuilder(a.argString()).append(ArgParser.EQUALS) |
| 161 |
|
.toString(); |
| 162 |
23 |
if (line.startsWith(s)) |
| 163 |
|
{ |
| 164 |
8 |
return line.substring(s.length()); |
| 165 |
|
} |
| 166 |
15 |
return null; |
| 167 |
|
} |
| 168 |
|
|
| |
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 169 |
5 |
private static Boolean getArgBoolean(Arg a, String line)... |
| 170 |
|
{ |
| 171 |
5 |
if (line.equals(a.argString())) |
| 172 |
|
{ |
| 173 |
2 |
return true; |
| 174 |
|
} |
| 175 |
3 |
if (line.equals(a.negateArgString())) |
| 176 |
|
{ |
| 177 |
3 |
return false; |
| 178 |
|
} |
| 179 |
0 |
return null; |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
} |