Clover icon

Coverage Report

  1. Project Clover database Tue Mar 10 2026 14:58:44 GMT
  2. Package jalview.bin.argparser

File StructuresFile.java

 

Coverage histogram

../../../img/srcFileCovDistChart0.png
0% of files have more coverage

Code metrics

20
55
14
1
182
153
24
0.44
3.93
14
1.71

Classes

Class Line # Actions
StructuresFile 19 55 24
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

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   
 
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   
 
36  0 toggle public StructuresFile(AlignmentI al, String filename)
37    {
38  0 alignment = al;
39  0 setStructureLines(parseStructuresFile(new File(filename)));
40    }
41   
 
42  0 toggle public boolean isSuperpose()
43    {
44  0 return superpose;
45    }
46   
 
47  0 toggle public void setSuperpose(boolean superpose)
48    {
49  0 this.superpose = superpose;
50    }
51   
 
52  0 toggle public String getViewerid()
53    {
54  0 return viewerid;
55    }
56   
 
57  0 toggle public void setViewerid(String viewerid)
58    {
59  0 this.viewerid = viewerid;
60    }
61   
 
62  0 toggle public ViewerType getViewerType()
63    {
64  0 return viewerType;
65    }
66   
 
67  0 toggle public void setViewerType(ViewerType viewerType)
68    {
69  0 this.viewerType = viewerType;
70    }
71   
 
72  0 toggle public List<StructureLine> getStructureLines()
73    {
74  0 return structureLines;
75    }
76   
 
77  0 toggle public void setStructureLines(List<StructureLine> structureLines)
78    {
79  0 this.structureLines = structureLines;
80    }
81   
 
82  0 toggle public List<StructureLine> parseStructuresFile(File structuresFile)
83    {
84  0 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  0 List<String> lines = ArgParser.readArgFile(structuresFile);
93  0 List<StructureLine> structurelines = new ArrayList<>();
94  0 if (lines != null)
95    {
96  0 for (String line : lines)
97    {
98  0 if (line.startsWith(ArgParser.DOUBLEDASH))
99    {
100  0 String val = getArgVal(Arg.VIEWERID, line);
101  0 if (val != null)
102    {
103  0 setViewerid(val);
104  0 continue;
105    }
106  0 val = getArgVal(Arg.STRUCTUREVIEWER, line);
107  0 if (val != null)
108    {
109  0 setViewerType(ViewerType.getFromString(val));
110  0 continue;
111    }
112  0 Boolean b = getArgBoolean(Arg.SUPERPOSE, line);
113  0 if (b != null)
114    {
115  0 setSuperpose(b);
116  0 continue;
117    }
118    }
119  0 StructureLine sl = new StructureLine(line);
120  0 structurelines.add(sl);
121  0 String structureLocationRef = sl.getSource();
122  0 DataSourceType structureLocationType = AppletFormatAdapter
123    .checkProtocol(structureLocationRef);
124  0 if (DataSourceType.FILE.equals(structureLocationType))
125    {
126  0 structureLocationRef = new File(structureLocationRef)
127    .getAbsolutePath();
128    }
129  0 SequenceI seq = alignment.findName(sl.getSeqid());
130   
131    // TODO get global or subval values for TFT and notempfac
132   
133  0 PDBEntry pdbEntry = AssociatePdbFileWithSeq
134    .associatePdbWithSeq(structureLocationRef,
135    structureLocationType, seq, false, Desktop.getInstance(),
136    null, null, false);
137   
138  0 pdbs.add(pdbEntry);
139  0 seqs.add(seq);
140   
141    }
142    }
143  0 return structurelines;
144    }
145   
 
146  0 toggle public SequenceI[] getSeqs()
147    {
148  0 SequenceI[] array = new SequenceI[seqs.size()];
149  0 return seqs.toArray(array);
150    }
151   
 
152  0 toggle public PDBEntry[] getPdbEntries()
153    {
154  0 PDBEntry[] array = new PDBEntry[pdbs.size()];
155  0 return pdbs.toArray(array);
156    }
157   
 
158  0 toggle private static String getArgVal(Arg a, String line)
159    {
160  0 String s = new StringBuilder(a.argString()).append(ArgParser.EQUALS)
161    .toString();
162  0 if (line.startsWith(s))
163    {
164  0 return line.substring(s.length());
165    }
166  0 return null;
167    }
168   
 
169  0 toggle private static Boolean getArgBoolean(Arg a, String line)
170    {
171  0 if (line.equals(a.argString()))
172    {
173  0 return true;
174    }
175  0 if (line.equals(a.negateArgString()))
176    {
177  0 return false;
178    }
179  0 return null;
180    }
181   
182    }