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.datamodel.Sequence; |
24 |
|
import jalview.datamodel.SequenceI; |
25 |
|
import jalview.util.Comparison; |
26 |
|
|
27 |
|
import java.io.IOException; |
28 |
|
import java.util.Vector; |
29 |
|
|
|
|
| 67.6% |
Uncovered Elements: 35 (108) |
Complexity: 24 |
Complexity Density: 0.35 |
|
30 |
|
public class PIRFile extends AlignFile |
31 |
|
{ |
32 |
|
public static boolean useModellerOutput = false; |
33 |
|
|
34 |
|
Vector words = new Vector(); |
35 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
36 |
3 |
public PIRFile()... |
37 |
|
{ |
38 |
|
} |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
40 |
0 |
public PIRFile(String inFile, DataSourceType sourceType)... |
41 |
|
throws IOException |
42 |
|
{ |
43 |
0 |
super(inFile, sourceType); |
44 |
|
} |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
1 |
public PIRFile(FileParse source) throws IOException... |
47 |
|
{ |
48 |
1 |
super(source); |
49 |
|
} |
50 |
|
|
|
|
| 76.9% |
Uncovered Elements: 9 (39) |
Complexity: 9 |
Complexity Density: 0.36 |
|
51 |
1 |
@Override... |
52 |
|
public void parse() throws IOException |
53 |
|
{ |
54 |
1 |
StringBuffer sequence; |
55 |
1 |
String line = null; |
56 |
1 |
ModellerDescription md; |
57 |
|
|
58 |
? |
while ((line = nextLine()) != null) |
59 |
|
{ |
60 |
15 |
if (line.length() == 0) |
61 |
|
{ |
62 |
|
|
63 |
0 |
continue; |
64 |
|
} |
65 |
15 |
if (line.indexOf("C;") == 0 || line.indexOf("#") == 0) |
66 |
|
{ |
67 |
0 |
continue; |
68 |
|
} |
69 |
15 |
Sequence newSeq = parseId(line.substring(line.indexOf(";") + 1)); |
70 |
|
|
71 |
15 |
sequence = new StringBuffer(); |
72 |
|
|
73 |
15 |
newSeq.setDescription(nextLine()); |
74 |
|
|
75 |
15 |
boolean starFound = false; |
76 |
|
|
77 |
60 |
while (!starFound) |
78 |
|
{ |
79 |
45 |
line = nextLine(); |
80 |
45 |
sequence.append(line); |
81 |
|
|
82 |
45 |
if (line == null) |
83 |
|
{ |
84 |
0 |
break; |
85 |
|
} |
86 |
|
|
87 |
45 |
if (line.indexOf("*") > -1) |
88 |
|
{ |
89 |
15 |
starFound = true; |
90 |
|
} |
91 |
|
} |
92 |
|
|
93 |
15 |
if (sequence.length() > 0) |
94 |
|
{ |
95 |
15 |
sequence.setLength(sequence.length() - 1); |
96 |
15 |
newSeq.setSequence(sequence.toString()); |
97 |
|
|
98 |
15 |
seqs.addElement(newSeq); |
99 |
|
|
100 |
15 |
md = new ModellerDescription(newSeq.getDescription()); |
101 |
15 |
md.updateSequenceI(newSeq); |
102 |
|
} |
103 |
|
} |
104 |
|
} |
105 |
|
|
|
|
| 61.3% |
Uncovered Elements: 24 (62) |
Complexity: 12 |
Complexity Density: 0.29 |
|
106 |
3 |
@Override... |
107 |
|
public String print(SequenceI[] s, boolean jvsuffix) |
108 |
|
{ |
109 |
3 |
boolean is_NA = Comparison.isNucleotide(s); |
110 |
3 |
int len = 72; |
111 |
3 |
StringBuffer out = new StringBuffer(); |
112 |
3 |
int i = 0; |
113 |
3 |
ModellerDescription md; |
114 |
|
|
115 |
48 |
while ((i < s.length) && (s[i] != null)) |
116 |
|
{ |
117 |
45 |
String seq = s[i].getSequenceAsString(); |
118 |
45 |
seq = seq + "*"; |
119 |
|
|
120 |
45 |
if (is_NA) |
121 |
|
{ |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
0 |
out.append(">N1;" + s[i].getName()); |
134 |
0 |
out.append(newline); |
135 |
0 |
if (s[i].getDescription() == null) |
136 |
|
{ |
137 |
0 |
out.append(s[i].getName() + " " |
138 |
|
+ (s[i].getEnd() - s[i].getStart() + 1)); |
139 |
0 |
out.append(is_NA ? " bases" : " residues"); |
140 |
0 |
out.append(newline); |
141 |
|
} |
142 |
|
else |
143 |
|
{ |
144 |
0 |
out.append(s[i].getDescription()); |
145 |
0 |
out.append(newline); |
146 |
|
} |
147 |
|
} |
148 |
|
else |
149 |
|
{ |
150 |
|
|
151 |
45 |
if (useModellerOutput) |
152 |
|
{ |
153 |
0 |
out.append(">P1;" + s[i].getName()); |
154 |
0 |
out.append(newline); |
155 |
0 |
md = new ModellerDescription(s[i]); |
156 |
0 |
out.append(md.getDescriptionLine()); |
157 |
0 |
out.append(newline); |
158 |
|
} |
159 |
|
else |
160 |
|
{ |
161 |
45 |
out.append(">P1;" + printId(s[i], jvsuffix)); |
162 |
45 |
out.append(newline); |
163 |
45 |
if (s[i].getDescription() != null) |
164 |
|
{ |
165 |
45 |
out.append(s[i].getDescription()); |
166 |
45 |
out.append(newline); |
167 |
|
} |
168 |
|
else |
169 |
|
{ |
170 |
0 |
out.append(s[i].getName() + " " |
171 |
|
+ (s[i].getEnd() - s[i].getStart() + 1) + " residues"); |
172 |
0 |
out.append(newline); |
173 |
|
} |
174 |
|
} |
175 |
|
} |
176 |
45 |
int nochunks = (seq.length() / len) |
177 |
45 |
+ (seq.length() % len > 0 ? 1 : 0); |
178 |
|
|
179 |
180 |
for (int j = 0; j < nochunks; j++) |
180 |
|
{ |
181 |
135 |
int start = j * len; |
182 |
135 |
int end = start + len; |
183 |
|
|
184 |
135 |
if (end < seq.length()) |
185 |
|
{ |
186 |
90 |
out.append(seq.substring(start, end)); |
187 |
90 |
out.append(newline); |
188 |
|
} |
189 |
45 |
else if (start < seq.length()) |
190 |
|
{ |
191 |
45 |
out.append(seq.substring(start)); |
192 |
45 |
out.append(newline); |
193 |
|
} |
194 |
|
} |
195 |
|
|
196 |
45 |
i++; |
197 |
|
} |
198 |
|
|
199 |
3 |
return out.toString(); |
200 |
|
} |
201 |
|
|
202 |
|
} |