| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.io; |
| 22 |
|
|
| 23 |
|
import java.io.File; |
| 24 |
|
import java.io.IOException; |
| 25 |
|
import java.util.Locale; |
| 26 |
|
|
| 27 |
|
import jalview.api.AlignExportSettingsI; |
| 28 |
|
import jalview.api.AlignmentViewPanel; |
| 29 |
|
import jalview.bin.Cache; |
| 30 |
|
import jalview.datamodel.Alignment; |
| 31 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 32 |
|
import jalview.datamodel.AlignmentI; |
| 33 |
|
import jalview.datamodel.HiddenColumns; |
| 34 |
|
import jalview.datamodel.Sequence; |
| 35 |
|
import jalview.datamodel.SequenceGroup; |
| 36 |
|
import jalview.datamodel.SequenceI; |
| 37 |
|
import jalview.structure.StructureImportSettings; |
| 38 |
|
import jalview.structure.StructureImportSettings.TFType; |
| 39 |
|
import jalview.util.Comparison; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
@author |
| 45 |
|
@version |
| 46 |
|
|
| |
|
| 0% |
Uncovered Elements: 100 (100) |
Complexity: 29 |
Complexity Density: 0.46 |
|
| 47 |
|
public class FormatAdapter extends AppletFormatAdapter |
| 48 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 49 |
0 |
public FormatAdapter(AlignmentViewPanel viewpanel)... |
| 50 |
|
{ |
| 51 |
0 |
super(viewpanel); |
| 52 |
0 |
init(); |
| 53 |
|
} |
| 54 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 55 |
0 |
public FormatAdapter()... |
| 56 |
|
{ |
| 57 |
0 |
super(); |
| 58 |
0 |
init(); |
| 59 |
|
} |
| 60 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 61 |
0 |
public FormatAdapter(AlignmentViewPanel alignPanel,... |
| 62 |
|
AlignExportSettingsI settings) |
| 63 |
|
{ |
| 64 |
0 |
super(alignPanel, settings); |
| 65 |
|
} |
| 66 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
| 67 |
0 |
private void init()... |
| 68 |
|
{ |
| 69 |
0 |
if (Cache.getDefault("STRUCT_FROM_PDB", true)) |
| 70 |
|
{ |
| 71 |
0 |
annotFromStructure = Cache.getDefault("ADD_TEMPFACT_ANN", true); |
| 72 |
0 |
localSecondaryStruct = Cache.getDefault("ADD_SS_ANN", true); |
| 73 |
0 |
serviceSecondaryStruct = Cache.getDefault("USE_RNAVIEW", true); |
| 74 |
|
} |
| 75 |
|
else |
| 76 |
|
{ |
| 77 |
|
|
| 78 |
0 |
annotFromStructure = false; |
| 79 |
0 |
localSecondaryStruct = false; |
| 80 |
0 |
serviceSecondaryStruct = false; |
| 81 |
|
} |
| 82 |
|
} |
| 83 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
0 |
public String formatSequences(FileFormatI format, SequenceI[] seqs,... |
| 85 |
|
String[] omitHiddenColumns, int[] exportRange) |
| 86 |
|
{ |
| 87 |
|
|
| 88 |
0 |
return formatSequences(format, |
| 89 |
|
replaceStrings(seqs, omitHiddenColumns, exportRange)); |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
@param |
| 97 |
|
@param |
| 98 |
|
@return |
| 99 |
|
|
| |
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 8 |
Complexity Density: 0.36 |
|
| 100 |
0 |
public SequenceI[] replaceStrings(SequenceI[] seqs,... |
| 101 |
|
String[] omitHiddenColumns, int[] startEnd) |
| 102 |
|
{ |
| 103 |
0 |
if (omitHiddenColumns != null) |
| 104 |
|
{ |
| 105 |
0 |
SequenceI[] tmp = new SequenceI[seqs.length]; |
| 106 |
|
|
| 107 |
0 |
int startRes; |
| 108 |
0 |
int endRes; |
| 109 |
0 |
int startIndex; |
| 110 |
0 |
int endIndex; |
| 111 |
0 |
for (int i = 0; i < seqs.length; i++) |
| 112 |
|
{ |
| 113 |
0 |
startRes = seqs[i].getStart(); |
| 114 |
0 |
endRes = seqs[i].getEnd(); |
| 115 |
0 |
if (startEnd != null) |
| 116 |
|
{ |
| 117 |
0 |
startIndex = startEnd[0]; |
| 118 |
0 |
endIndex = startEnd[1]; |
| 119 |
|
|
| 120 |
0 |
while (Comparison.isGap(seqs[i].getCharAt(startIndex)) |
| 121 |
|
&& startIndex < endIndex) |
| 122 |
|
{ |
| 123 |
0 |
startIndex++; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
|
|
| 127 |
0 |
while (Comparison.isGap(seqs[i].getCharAt(endIndex)) |
| 128 |
|
&& endIndex > startIndex) |
| 129 |
|
{ |
| 130 |
0 |
endIndex--; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
0 |
startRes = seqs[i].findPosition(startIndex); |
| 134 |
0 |
endRes = seqs[i].findPosition(endIndex); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
0 |
tmp[i] = new Sequence(seqs[i].getName(), omitHiddenColumns[i], |
| 138 |
|
startRes, endRes); |
| 139 |
0 |
tmp[i].setDescription(seqs[i].getDescription()); |
| 140 |
|
} |
| 141 |
0 |
seqs = tmp; |
| 142 |
|
} |
| 143 |
0 |
return seqs; |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
@param |
| 152 |
|
@param |
| 153 |
|
|
| 154 |
|
|
| 155 |
|
@return |
| 156 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 157 |
0 |
public String formatSequences(FileFormatI format, SequenceI[] seqs)... |
| 158 |
|
{ |
| 159 |
0 |
boolean withSuffix = getCacheSuffixDefault(format); |
| 160 |
0 |
return format.getWriter(null).print(seqs, withSuffix); |
| 161 |
|
} |
| 162 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 163 |
0 |
public boolean getCacheSuffixDefault(FileFormatI format)... |
| 164 |
|
{ |
| 165 |
0 |
return Cache.getDefault( |
| 166 |
|
format.getName().toUpperCase(Locale.ROOT) + "_JVSUFFIX", true); |
| 167 |
|
} |
| 168 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 169 |
0 |
public String formatSequences(FileFormatI format, AlignmentI alignment,... |
| 170 |
|
String[] omitHidden, int[] exportRange, HiddenColumns hidden) |
| 171 |
|
{ |
| 172 |
0 |
return formatSequences(format, alignment, omitHidden, exportRange, |
| 173 |
|
getCacheSuffixDefault(format), hidden, null); |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
@param |
| 181 |
|
@param |
| 182 |
|
@param |
| 183 |
|
|
| 184 |
|
@param |
| 185 |
|
|
| 186 |
|
@return |
| 187 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 188 |
0 |
public String formatSequences(FileFormatI format, AlignmentI alignment,... |
| 189 |
|
String[] omitHidden, int[] exportRange, boolean suffix, |
| 190 |
|
HiddenColumns hidden) |
| 191 |
|
{ |
| 192 |
0 |
return formatSequences(format, alignment, omitHidden, exportRange, |
| 193 |
|
suffix, hidden, null); |
| 194 |
|
} |
| 195 |
|
|
| |
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.42 |
|
| 196 |
0 |
public String formatSequences(FileFormatI format, AlignmentI alignment,... |
| 197 |
|
String[] omitHidden, int[] exportRange, boolean suffix, |
| 198 |
|
HiddenColumns hidden, SequenceGroup selgp) |
| 199 |
|
{ |
| 200 |
0 |
if (omitHidden != null) |
| 201 |
|
{ |
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
0 |
Alignment alv = new Alignment(replaceStrings( |
| 207 |
|
alignment.getSequencesArray(), omitHidden, exportRange)); |
| 208 |
0 |
AlignmentAnnotation[] ala = alignment.getAlignmentAnnotation(); |
| 209 |
0 |
if (ala != null) |
| 210 |
|
{ |
| 211 |
0 |
for (int i = 0; i < ala.length; i++) |
| 212 |
|
{ |
| 213 |
0 |
AlignmentAnnotation na = new AlignmentAnnotation(ala[i]); |
| 214 |
0 |
if (selgp != null) |
| 215 |
|
{ |
| 216 |
0 |
na.makeVisibleAnnotation(selgp.getStartRes(), selgp.getEndRes(), |
| 217 |
|
hidden); |
| 218 |
|
} |
| 219 |
|
else |
| 220 |
|
{ |
| 221 |
0 |
na.makeVisibleAnnotation(hidden); |
| 222 |
|
} |
| 223 |
0 |
alv.addAnnotation(na); |
| 224 |
|
} |
| 225 |
|
} |
| 226 |
0 |
return this.formatSequences(format, alv, suffix); |
| 227 |
|
} |
| 228 |
0 |
return this.formatSequences(format, alignment, suffix); |
| 229 |
|
} |
| 230 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 231 |
0 |
@Override... |
| 232 |
|
public AlignmentI readFile(File selectedFile, String file, |
| 233 |
|
DataSourceType sourceType, FileFormatI fileFormat, |
| 234 |
|
StructureImportSettings.TFType tempfacType) throws IOException |
| 235 |
|
{ |
| 236 |
0 |
AlignmentI al = super.readFile(selectedFile, file, sourceType, |
| 237 |
|
fileFormat, tempfacType); |
| 238 |
0 |
return al; |
| 239 |
|
} |
| 240 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 241 |
0 |
@Override... |
| 242 |
|
public AlignmentI readFile(String file, DataSourceType sourceType, |
| 243 |
|
FileFormatI fileFormat) throws IOException |
| 244 |
|
{ |
| 245 |
0 |
AlignmentI al = super.readFile(file, sourceType, fileFormat); |
| 246 |
0 |
return al; |
| 247 |
|
} |
| 248 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 249 |
0 |
public AlignmentI readFile(File file, DataSourceType sourceType,... |
| 250 |
|
FileFormatI fileFormat) throws IOException |
| 251 |
|
{ |
| 252 |
0 |
AlignmentI al = super.readFile(file, null, sourceType, fileFormat); |
| 253 |
0 |
return al; |
| 254 |
|
} |
| 255 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 256 |
0 |
@Override... |
| 257 |
|
public AlignmentI readFromFile(FileParse source, FileFormatI format) |
| 258 |
|
throws IOException |
| 259 |
|
{ |
| 260 |
0 |
AlignmentI al = super.readFromFile(source, format); |
| 261 |
0 |
return al; |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
|
| 268 |
|
@param |
| 269 |
|
@param |
| 270 |
|
|
| 271 |
|
@return |
| 272 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 273 |
0 |
public String formatSequences(FileFormatI format, AlignmentViewPanel ap,... |
| 274 |
|
boolean selectedOnly) |
| 275 |
|
{ |
| 276 |
0 |
return formatSequences(format, getCacheSuffixDefault(format), ap, |
| 277 |
|
selectedOnly); |
| 278 |
|
} |
| 279 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 280 |
0 |
public AlignmentI readFromFile(AlignmentFileReaderI source,... |
| 281 |
|
FileFormatI format) throws IOException |
| 282 |
|
{ |
| 283 |
0 |
FileParse fp = new FileParse(source.getInFile(), |
| 284 |
|
source.getDataSourceType()); |
| 285 |
0 |
return readFromFile(fp, format); |
| 286 |
|
} |
| 287 |
|
|
| 288 |
|
} |