git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
301974b
)
more efficient parsing of large files, do not create sequence features from GR annota...
author
jprocter
<Jim Procter>
Tue, 22 Jan 2008 16:16:30 +0000
(16:16 +0000)
committer
jprocter
<Jim Procter>
Tue, 22 Jan 2008 16:16:30 +0000
(16:16 +0000)
src/jalview/io/StockholmFile.java
patch
|
blob
|
history
diff --git
a/src/jalview/io/StockholmFile.java
b/src/jalview/io/StockholmFile.java
index
bac1916
..
945b8c5
100644
(file)
--- a/
src/jalview/io/StockholmFile.java
+++ b/
src/jalview/io/StockholmFile.java
@@
-124,7
+124,7
@@
public class StockholmFile extends AlignFile
{
\r
String acc = (String) accs.nextElement();
\r
// logger.debug("Processing sequence " + acc);
\r
{
\r
String acc = (String) accs.nextElement();
\r
// logger.debug("Processing sequence " + acc);
\r
- String seq = (String) seqs.get(acc);
\r
+ String seq = (String) seqs.remove(acc);
\r
if (maxLength < seq.length())
\r
{
\r
maxLength = seq.length();
\r
if (maxLength < seq.length())
\r
{
\r
maxLength = seq.length();
\r
@@
-137,7
+137,7
@@
public class StockholmFile extends AlignFile
\r
if (seqAnn != null && seqAnn.containsKey(acc))
\r
{
\r
\r
if (seqAnn != null && seqAnn.containsKey(acc))
\r
{
\r
- accAnnotations = (Hashtable) seqAnn.get(acc);
\r
+ accAnnotations = (Hashtable) seqAnn.remove(acc);
\r
}
\r
\r
// Split accession in id and from/to
\r
}
\r
\r
// Split accession in id and from/to
\r
@@
-172,7
+172,7
@@
public class StockholmFile extends AlignFile
// We need to adjust the positions of all features to account for gaps
\r
try
\r
{
\r
// We need to adjust the positions of all features to account for gaps
\r
try
\r
{
\r
- features = (Hashtable) accAnnotations.get("features");
\r
+ features = (Hashtable) accAnnotations.remove("features");
\r
} catch (java.lang.NullPointerException e)
\r
{
\r
// loggerwarn("Getting Features for " + acc + ": " +
\r
} catch (java.lang.NullPointerException e)
\r
{
\r
// loggerwarn("Getting Features for " + acc + ": " +
\r
@@
-182,6
+182,7
@@
public class StockholmFile extends AlignFile
// if we have features
\r
if (features != null)
\r
{
\r
// if we have features
\r
if (features != null)
\r
{
\r
+ int posmap[] = seqO.findPositionMap();
\r
Enumeration i = features.keys();
\r
while (i.hasMoreElements())
\r
{
\r
Enumeration i = features.keys();
\r
while (i.hasMoreElements())
\r
{
\r
@@
-190,8
+191,7
@@
public class StockholmFile extends AlignFile
// TODO: parse out scores as annotation row
\r
// TODO: map coding region to core jalview feature types
\r
String type = i.nextElement().toString();
\r
// TODO: parse out scores as annotation row
\r
// TODO: map coding region to core jalview feature types
\r
String type = i.nextElement().toString();
\r
- Hashtable content = (Hashtable) features.get(type);
\r
-
\r
+ Hashtable content = (Hashtable) features.remove(type);
\r
Enumeration j = content.keys();
\r
while (j.hasMoreElements())
\r
{
\r
Enumeration j = content.keys();
\r
while (j.hasMoreElements())
\r
{
\r
@@
-201,9
+201,9
@@
public class StockholmFile extends AlignFile
for (int k = 0; k < byChar.length; k++)
\r
{
\r
char c = byChar[k];
\r
for (int k = 0; k < byChar.length; k++)
\r
{
\r
char c = byChar[k];
\r
- if (!(c == ' ' || c == '_' || c == '-'))
\r
+ if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM uses '.' for feature background
\r
{
\r
{
\r
- int new_pos = seqO.findPosition(k);
\r
+ int new_pos = posmap[k]; // look up nearest seqeunce position to this column
\r
SequenceFeature feat = new SequenceFeature(type, desc,
\r
new_pos, new_pos, 0f, null);
\r
\r
SequenceFeature feat = new SequenceFeature(type, desc,
\r
new_pos, new_pos, 0f, null);
\r
\r
@@
-213,8
+213,10
@@
public class StockholmFile extends AlignFile
}
\r
\r
}
\r
}
\r
\r
}
\r
-
\r
+
\r
}
\r
}
\r
+ // garbage collect
\r
+
\r
// logger.debug("Adding seq " + acc + " from " + start + " to " + end
\r
// + ": " + seq);
\r
this.seqs.addElement(seqO);
\r
// logger.debug("Adding seq " + acc + " from " + start + " to " + end
\r
// + ": " + seq);
\r
this.seqs.addElement(seqO);
\r
@@
-370,14
+372,18
@@
public class StockholmFile extends AlignFile
{
\r
String acc = s.stringMatched(1);
\r
String type = s.stringMatched(2);
\r
{
\r
String acc = s.stringMatched(1);
\r
String type = s.stringMatched(2);
\r
- String seq = s.stringMatched(3);
\r
- String description = new String();
\r
-
\r
+ String seq = new String(s.stringMatched(3));
\r
+ String description = null;
\r
// Check for additional information about the current annotation
\r
// Check for additional information about the current annotation
\r
- if (x.search(seq))
\r
+ // We use a simple string tokenizer here for speed
\r
+ StringTokenizer sep = new StringTokenizer(seq," \t");
\r
+ description = sep.nextToken();
\r
+ if (sep.hasMoreTokens())
\r
{
\r
{
\r
- description = x.stringMatched(1);
\r
- seq = x.stringMatched(2);
\r
+ seq = sep.nextToken();
\r
+ } else {
\r
+ seq = description;
\r
+ description = new String();
\r
}
\r
// sequence id with from-to fields
\r
\r
}
\r
// sequence id with from-to fields
\r
\r