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:
c834ec0
)
basic methods for adding scores extracted from description
author
jprocter
<Jim Procter>
Thu, 26 Apr 2007 10:36:42 +0000
(10:36 +0000)
committer
jprocter
<Jim Procter>
Thu, 26 Apr 2007 10:36:42 +0000
(10:36 +0000)
src/jalview/analysis/ParseProperties.java
patch
|
blob
|
history
diff --git
a/src/jalview/analysis/ParseProperties.java
b/src/jalview/analysis/ParseProperties.java
index
015fcfe
..
c23cb3a
100644
(file)
--- a/
src/jalview/analysis/ParseProperties.java
+++ b/
src/jalview/analysis/ParseProperties.java
@@
-8,6
+8,14
@@
public class ParseProperties
{
\r
/**
\r
* Methods for parsing free text properties on alignments and sequences.
\r
{
\r
/**
\r
* Methods for parsing free text properties on alignments and sequences.
\r
+ * There are a number of ways we might want to do this:
\r
+ * arbitrary regex. and an associated score name for the number that's extracted.
\r
+ * Regex that provides both score and name.
\r
+ *
\r
+ * We may also want to :
\r
+ * - modify description to remove parsed numbers (this behaviour is dangerous since exporting the alignment would lose the original form then)
\r
+ * -
\r
+ *
\r
*/
\r
/**
\r
* The alignment being operated on
\r
*/
\r
/**
\r
* The alignment being operated on
\r
@@
-18,7
+26,7
@@
public class ParseProperties
* initialise a new property parser
\r
* @param al
\r
*/
\r
* initialise a new property parser
\r
* @param al
\r
*/
\r
- ParseProperties(AlignmentI al) {
\r
+ public ParseProperties(AlignmentI al) {
\r
this.al = al;
\r
}
\r
\r
this.al = al;
\r
}
\r
\r
@@
-51,10
+59,10
@@
public class ParseProperties
System.arraycopy(ScoreNames, 0, tnames, 0, ScoreNames.length);
\r
String base = tnames[ScoreNames.length-1];
\r
ScoreNames = tnames;
\r
System.arraycopy(ScoreNames, 0, tnames, 0, ScoreNames.length);
\r
String base = tnames[ScoreNames.length-1];
\r
ScoreNames = tnames;
\r
- String descrbase = ScoreDescriptions[ScoreNames.length-1];
\r
+ String descrbase = ScoreDescriptions[onamelen-1];
\r
if (descrbase == null)
\r
descrbase = "Score parsed from ("+regex+")";
\r
if (descrbase == null)
\r
descrbase = "Score parsed from ("+regex+")";
\r
- tnames = new String[pattern.numSubs()];
\r
+ tnames = new String[pattern.numSubs()+1];
\r
System.arraycopy(ScoreDescriptions, 0, tnames, 0, ScoreDescriptions.length);
\r
ScoreDescriptions = tnames;
\r
for (int i=onamelen; i<ScoreNames.length; i++)
\r
System.arraycopy(ScoreDescriptions, 0, tnames, 0, ScoreDescriptions.length);
\r
ScoreDescriptions = tnames;
\r
for (int i=onamelen; i<ScoreNames.length; i++)
\r
@@
-66,12
+74,14
@@
public class ParseProperties
for (int i=0; i<seqs.length; i++)
\r
{
\r
String descr = seqs[i].getDescription();
\r
for (int i=0; i<seqs.length; i++)
\r
{
\r
String descr = seqs[i].getDescription();
\r
+ if (descr==null)
\r
+ continue;
\r
if (pattern.search(descr))
\r
{
\r
boolean added=false;
\r
for (int cols=0; cols<pattern.numSubs(); cols++)
\r
{
\r
if (pattern.search(descr))
\r
{
\r
boolean added=false;
\r
for (int cols=0; cols<pattern.numSubs(); cols++)
\r
{
\r
- String sstring = pattern.stringMatched(cols);
\r
+ String sstring = pattern.stringMatched(cols+1);
\r
float score;
\r
try {
\r
score = new Float(sstring).floatValue();
\r
float score;
\r
try {
\r
score = new Float(sstring).floatValue();
\r
@@
-107,10
+117,10
@@
public class ParseProperties
//seqs[4].setDescription("5 mydescription5");
\r
Alignment al = new Alignment(seqs);
\r
ParseProperties pp = new ParseProperties(al);
\r
//seqs[4].setDescription("5 mydescription5");
\r
Alignment al = new Alignment(seqs);
\r
ParseProperties pp = new ParseProperties(al);
\r
- String regex = ".*([-0-9.+]+).*";
\r
+ String regex = ".*([-0-9.+]+)";
\r
System.out.println("Matched "+pp.getScoresFromDescription("my Score", "my Score Description",regex)+" for "+regex);
\r
regex = ".*([-0-9.+]+).+([-0-9.+]+).*";
\r
System.out.println("Matched "+pp.getScoresFromDescription("my Score", "my Score Description",regex)+" for "+regex);
\r
System.out.println("Matched "+pp.getScoresFromDescription("my Score", "my Score Description",regex)+" for "+regex);
\r
regex = ".*([-0-9.+]+).+([-0-9.+]+).*";
\r
System.out.println("Matched "+pp.getScoresFromDescription("my Score", "my Score Description",regex)+" for "+regex);
\r
-
\r
+ System.out.println("Finished.");
\r
}
\r
}
\r
}
\r
}
\r