| 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 jalview.analysis.Rna; |
| 24 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 25 |
|
import jalview.datamodel.Annotation; |
| 26 |
|
import jalview.datamodel.Sequence; |
| 27 |
|
import jalview.datamodel.SequenceI; |
| 28 |
|
import jalview.util.MessageManager; |
| 29 |
|
|
| 30 |
|
import java.io.BufferedReader; |
| 31 |
|
import java.io.FileNotFoundException; |
| 32 |
|
import java.io.FileReader; |
| 33 |
|
import java.io.IOException; |
| 34 |
|
import java.util.ArrayList; |
| 35 |
|
import java.util.List; |
| 36 |
|
|
| 37 |
|
import com.stevesoft.pat.Regex; |
| 38 |
|
|
| 39 |
|
import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax; |
| 40 |
|
import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed; |
| 41 |
|
import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied; |
| 42 |
|
import fr.orsay.lri.varna.factories.RNAFactory; |
| 43 |
|
import fr.orsay.lri.varna.models.rna.RNA; |
| 44 |
|
|
| |
|
| 68.2% |
Uncovered Elements: 28 (88) |
Complexity: 25 |
Complexity Density: 0.42 |
|
| 45 |
|
public class RnamlFile extends AlignFile |
| 46 |
|
{ |
| 47 |
|
public String id; |
| 48 |
|
|
| 49 |
|
protected ArrayList<RNA> result; |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 51 |
0 |
public RnamlFile()... |
| 52 |
|
{ |
| 53 |
0 |
super(); |
| 54 |
|
|
| 55 |
|
} |
| 56 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 57 |
1 |
public RnamlFile(String inFile, DataSourceType type) throws IOException... |
| 58 |
|
{ |
| 59 |
1 |
super(inFile, type); |
| 60 |
|
|
| 61 |
|
} |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
1 |
public RnamlFile(FileParse source) throws IOException... |
| 64 |
|
{ |
| 65 |
1 |
super(source); |
| 66 |
|
|
| 67 |
|
} |
| 68 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 69 |
0 |
public BufferedReader CreateReader() throws FileNotFoundException... |
| 70 |
|
{ |
| 71 |
0 |
FileReader fr = null; |
| 72 |
0 |
fr = new FileReader(inFile); |
| 73 |
|
|
| 74 |
0 |
BufferedReader r = new BufferedReader(fr); |
| 75 |
0 |
return r; |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
@see |
| 82 |
|
|
| |
|
| 26.7% |
Uncovered Elements: 11 (15) |
Complexity: 7 |
Complexity Density: 0.54 |
|
| 83 |
2 |
@Override... |
| 84 |
|
public void parse() throws IOException |
| 85 |
|
{ |
| 86 |
2 |
if (System.getProperty("java.version").indexOf("1.6") > -1 |
| 87 |
|
|| System.getProperty("java.version").indexOf("1.5") > -1) |
| 88 |
|
{ |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
0 |
System.setProperty("javax.xml.parsers.SAXParserFactory", |
| 95 |
|
"com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl"); |
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
2 |
try |
| 101 |
|
{ |
| 102 |
2 |
_parse(); |
| 103 |
|
} catch (ExceptionPermissionDenied pdx) |
| 104 |
|
{ |
| 105 |
0 |
errormessage = MessageManager.formatMessage( |
| 106 |
|
"exception.rnaml_couldnt_access_datasource", new String[] |
| 107 |
|
{ pdx.getMessage() }); |
| 108 |
0 |
throw new IOException(pdx); |
| 109 |
|
} catch (ExceptionLoadingFailed lf) |
| 110 |
|
{ |
| 111 |
0 |
errormessage = MessageManager.formatMessage( |
| 112 |
|
"exception.ranml_couldnt_process_data", new String[] |
| 113 |
|
{ lf.getMessage() }); |
| 114 |
0 |
throw new IOException(lf); |
| 115 |
|
} catch (ExceptionFileFormatOrSyntax iff) |
| 116 |
|
{ |
| 117 |
0 |
errormessage = MessageManager |
| 118 |
|
.formatMessage("exception.ranml_invalid_file", new String[] |
| 119 |
|
{ iff.getMessage() }); |
| 120 |
0 |
throw new IOException(iff); |
| 121 |
|
} catch (Exception x) |
| 122 |
|
{ |
| 123 |
0 |
error = true; |
| 124 |
0 |
errormessage = MessageManager.formatMessage( |
| 125 |
|
"exception.ranml_problem_parsing_data", new String[] |
| 126 |
|
{ x.getMessage() }); |
| 127 |
0 |
throw new IOException(errormessage, x); |
| 128 |
|
} |
| 129 |
|
} |
| 130 |
|
|
| |
|
| 90.2% |
Uncovered Elements: 4 (41) |
Complexity: 9 |
Complexity Density: 0.33 |
|
| 131 |
2 |
@SuppressWarnings("unchecked")... |
| 132 |
|
public void _parse() |
| 133 |
|
throws FileNotFoundException, ExceptionPermissionDenied, |
| 134 |
|
ExceptionLoadingFailed, ExceptionFileFormatOrSyntax |
| 135 |
|
{ |
| 136 |
|
|
| 137 |
2 |
result = RNAFactory.loadSecStrRNAML(getReader()); |
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
2 |
SequenceI[] sqs = new SequenceI[result.size()]; |
| 143 |
|
|
| 144 |
5 |
for (int i = 0; i < result.size(); i++) |
| 145 |
|
{ |
| 146 |
|
|
| 147 |
3 |
RNA current = result.get(i); |
| 148 |
3 |
String rna = current.getStructDBN(true); |
| 149 |
3 |
String seq = current.getSeq(); |
| 150 |
3 |
int begin = 1; |
| 151 |
3 |
int end = seq.length(); |
| 152 |
|
|
| 153 |
3 |
id = current.getName(); |
| 154 |
3 |
if (id == null || id.trim().length() == 0) |
| 155 |
|
{ |
| 156 |
3 |
id = safeName(getDataName()); |
| 157 |
3 |
if (result.size() > 1) |
| 158 |
|
{ |
| 159 |
2 |
id += "." + i; |
| 160 |
|
} |
| 161 |
|
} |
| 162 |
3 |
sqs[i] = new Sequence(id, seq, begin, end); |
| 163 |
3 |
if (seq.length() != (end - begin + 1)) |
| 164 |
|
{ |
| 165 |
0 |
sqs[i].setEnd(sqs[i].findPosition(sqs[i].getLength())); |
| 166 |
|
} |
| 167 |
3 |
String[] annot = new String[rna.length()]; |
| 168 |
3 |
Annotation[] ann = new Annotation[rna.length()]; |
| 169 |
|
|
| 170 |
566 |
for (int j = 0; j < rna.length(); j++) |
| 171 |
|
{ |
| 172 |
563 |
annot[j] = "" + rna.charAt(j); |
| 173 |
|
|
| 174 |
|
} |
| 175 |
566 |
for (int k = 0; k < rna.length(); k++) |
| 176 |
|
{ |
| 177 |
563 |
ann[k] = new Annotation(annot[k], "", |
| 178 |
|
Rna.getRNASecStrucState(annot[k]).charAt(0), 0f); |
| 179 |
|
} |
| 180 |
|
|
| 181 |
3 |
AlignmentAnnotation align = new AlignmentAnnotation( |
| 182 |
|
"Secondary Structure", |
| 183 |
3 |
current.getID().trim().length() > 0 |
| 184 |
|
? "Secondary Structure for " + current.getID() |
| 185 |
|
: "", |
| 186 |
|
ann); |
| 187 |
|
|
| 188 |
3 |
sqs[i].addAlignmentAnnotation(align); |
| 189 |
3 |
sqs[i].setRNA(result.get(i)); |
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
3 |
annotations.addElement(align); |
| 194 |
|
|
| 195 |
|
|
| 196 |
|
} |
| 197 |
|
|
| 198 |
2 |
setSeqs(sqs); |
| 199 |
|
} |
| 200 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 201 |
0 |
@Override... |
| 202 |
|
public String print(SequenceI[] s, boolean jvSuffix) |
| 203 |
|
{ |
| 204 |
0 |
return "not yet implemented"; |
| 205 |
|
} |
| 206 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 207 |
0 |
public List<RNA> getRNA()... |
| 208 |
|
{ |
| 209 |
0 |
return result; |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
@param |
| 222 |
|
@return |
| 223 |
|
|
| |
|
| 85.7% |
Uncovered Elements: 2 (14) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 224 |
3 |
private String safeName(String dataName)... |
| 225 |
|
{ |
| 226 |
3 |
int b = 0; |
| 227 |
? |
if ((b = dataName.lastIndexOf(".")) > 0) |
| 228 |
|
{ |
| 229 |
3 |
dataName = dataName.substring(0, b - 1); |
| 230 |
|
} |
| 231 |
3 |
b = 0; |
| 232 |
3 |
Regex m = new Regex("[\\/]?([-A-Za-z0-9]+)\\.?"); |
| 233 |
3 |
String mm = dataName; |
| 234 |
12 |
while (m.searchFrom(dataName, b)) |
| 235 |
|
{ |
| 236 |
9 |
mm = m.stringMatched(); |
| 237 |
9 |
b = m.matchedTo(); |
| 238 |
|
} |
| 239 |
3 |
return mm; |
| 240 |
|
} |
| 241 |
|
} |