From 8630b85f5394dfbc86a6c3c22ec17ffcc6ed1ea1 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 27 Apr 2007 12:23:33 +0000 Subject: [PATCH] parsers can generate alignment properties --- src/jalview/io/AlignFile.java | 57 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index ae8e0d0e..3c7e0b2 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -34,8 +34,18 @@ public abstract class AlignFile { int noSeqs = 0; int maxLength = 0; + /** + * Sequences to be added to form a new alignment. + */ protected Vector seqs; + /** + * annotation to be added to generated alignment object + */ protected Vector annotations; + /** + * Properties to be added to generated alignment object + */ + protected Hashtable properties; long start; long end; boolean jvSuffix = true; @@ -84,9 +94,15 @@ public abstract class AlignFile return s; } - + /** + * called by AppletFormatAdapter to generate + * an annotated alignment, rather than bare + * sequences. + * @param al + */ public void addAnnotations(Alignment al) { + addProperties(al); for (int i = 0; i < annotations.size(); i++) { al.addAnnotation( @@ -95,7 +111,44 @@ public abstract class AlignFile } } - + /** + * Add any additional information extracted + * from the file to the alignment properties. + * @note implicitly called by addAnnotations() + * @param al + */ + public void addProperties(Alignment al) + { + if (properties!=null && properties.size()>0) + { + Enumeration keys = properties.keys(); + Enumeration vals = properties.elements(); + while (keys.hasMoreElements()) + { + al.setProperty(keys.nextElement(), vals.nextElement()); + } + } + } + protected void setAlignmentProperty(Object key, Object value) + { + if (key==null) + { + throw new Error("Implementation error: Cannot have null alignment property key."); + } + if (properties==null) + { + properties = new Hashtable(); + } + properties.put(key, value); + } + protected Object getAlignmentProperty(Object key) + { + if (properties!=null && key!=null) + { + return properties.get(key); + } + return null; + } /** * Initialise objects to store sequence data in. */ -- 1.7.10.2