git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'Jalview-BH/JAL-3026-JAL-3063-JAXB' of https://source.jalview.org/git...
[jalview.git]
/
src
/
jalview
/
io
/
AlignFile.java
diff --git
a/src/jalview/io/AlignFile.java
b/src/jalview/io/AlignFile.java
index
5760fbe
..
cea2870
100755
(executable)
--- a/
src/jalview/io/AlignFile.java
+++ b/
src/jalview/io/AlignFile.java
@@
-41,6
+41,7
@@
import java.util.Vector;
* @version $Revision$
*/
public abstract class AlignFile extends FileParse
* @version $Revision$
*/
public abstract class AlignFile extends FileParse
+ implements AlignmentFileReaderI, AlignmentFileWriterI
{
int noSeqs = 0;
{
int noSeqs = 0;
@@
-65,15
+66,26
@@
public abstract class AlignFile extends FileParse
/**
* Properties to be added to generated alignment object
*/
/**
* Properties to be added to generated alignment object
*/
- protected Hashtable properties;
+ private Hashtable properties;
long start;
long end;
long start;
long end;
- boolean jvSuffix = true;
+ /**
+ * true if parse() has been called
+ */
+ private boolean parseCalled = false;
- private boolean parseCalled;
+ private boolean parseImmediately = true;
+
+ /**
+ * @return if doParse() was called at construction time
+ */
+ protected boolean isParseImmediately()
+ {
+ return parseImmediately;
+ }
/**
* Creates a new AlignFile object.
/**
* Creates a new AlignFile object.
@@
-86,17
+98,24
@@
public abstract class AlignFile extends FileParse
initData();
}
initData();
}
+ public AlignFile(SequenceI[] seqs)
+ {
+ this();
+ setSeqs(seqs);
+ }
+
/**
* Constructor which parses the data from a file of some specified type.
*
* @param dataObject
* Filename, URL or Pasted String to read from.
/**
* Constructor which parses the data from a file of some specified type.
*
* @param dataObject
* Filename, URL or Pasted String to read from.
- * @param type
+ * @param sourceType
* What type of file to read from (File, URL, Pasted String)
*/
* What type of file to read from (File, URL, Pasted String)
*/
- public AlignFile(String dataObject, String type) throws IOException
+ public AlignFile(Object dataObject, DataSourceType sourceType)
+ throws IOException
{
{
- this(true, dataObject, type);
+ this(true, dataObject, sourceType);
}
/**
}
/**
@@
-107,14
+126,15
@@
public abstract class AlignFile extends FileParse
* if false, need to call 'doParse()' to begin parsing data
* @param dataObject
* Filename, URL or Pasted String to read from.
* if false, need to call 'doParse()' to begin parsing data
* @param dataObject
* Filename, URL or Pasted String to read from.
- * @param type
+ * @param sourceType
* What type of file to read from (File, URL)
* @throws IOException
*/
* What type of file to read from (File, URL)
* @throws IOException
*/
- public AlignFile(boolean parseImmediately, String dataObject, String type)
- throws IOException
+ public AlignFile(boolean parseImmediately, Object dataObject,
+ DataSourceType sourceType) throws IOException
{
{
- super(dataObject, type);
+ // BH allows File or String
+ super(dataObject, sourceType);
initData();
if (parseImmediately)
{
initData();
if (parseImmediately)
{
@@
-147,6
+167,11
@@
public abstract class AlignFile extends FileParse
{
super(source);
initData();
{
super(source);
initData();
+
+ // stash flag in case parse needs to know if it has to autoconfigure or was
+ // configured after construction
+ this.parseImmediately = parseImmediately;
+
if (parseImmediately)
{
doParse();
if (parseImmediately)
{
doParse();
@@
-168,11
+193,6
@@
public abstract class AlignFile extends FileParse
}
parseCalled = true;
parse();
}
parseCalled = true;
parse();
- // sets the index of each sequence in the alignment
- for (int i = 0, c = seqs.size(); i < c; i++)
- {
- seqs.get(i).setIndex(i);
- }
}
/**
}
/**
@@
-191,6
+211,7
@@
public abstract class AlignFile extends FileParse
/**
* Return the Sequences in the seqs Vector as an array of Sequences
*/
/**
* Return the Sequences in the seqs Vector as an array of Sequences
*/
+ @Override
public SequenceI[] getSeqsAsArray()
{
SequenceI[] s = new SequenceI[seqs.size()];
public SequenceI[] getSeqsAsArray()
{
SequenceI[] s = new SequenceI[seqs.size()];
@@
-209,6
+230,7
@@
public abstract class AlignFile extends FileParse
*
* @param al
*/
*
* @param al
*/
+ @Override
public void addAnnotations(AlignmentI al)
{
addProperties(al);
public void addAnnotations(AlignmentI al)
{
addProperties(al);
@@
-273,9
+295,8
@@
public abstract class AlignFile extends FileParse
{
if (key == null)
{
{
if (key == null)
{
- throw new Error(
- MessageManager
- .getString("error.implementation_error_cannot_have_null_alignment"));
+ throw new Error(MessageManager.getString(
+ "error.implementation_error_cannot_have_null_alignment"));
}
if (value == null)
{
}
if (value == null)
{
@@
-314,7
+335,8
@@
public abstract class AlignFile extends FileParse
* @param s
* DOCUMENT ME!
*/
* @param s
* DOCUMENT ME!
*/
- protected void setSeqs(SequenceI[] s)
+ @Override
+ public void setSeqs(SequenceI[] s)
{
seqs = new Vector<SequenceI>();
{
seqs = new Vector<SequenceI>();
@@
-330,16
+352,6
@@
public abstract class AlignFile extends FileParse
public abstract void parse() throws IOException;
/**
public abstract void parse() throws IOException;
/**
- * Print out in alignment file format the Sequences in the seqs Vector.
- */
- public abstract String print();
-
- public void addJVSuffix(boolean b)
- {
- jvSuffix = b;
- }
-
- /**
* A general parser for ids.
*
* @String id Id to be parsed
* A general parser for ids.
*
* @String id Id to be parsed
@@
-371,14
+383,21
@@
public abstract class AlignFile extends FileParse
}
/**
}
/**
- * Creates the output id. Adds prefix Uniprot format source|id And suffix
- * Jalview /start-end
+ * Creates the output id. Adds prefix Uniprot format source|id and optionally
+ * suffix Jalview /start-end
+ *
+ * @param jvsuffix
*
* @String id Id to be parsed
*/
*
* @String id Id to be parsed
*/
+ String printId(SequenceI seq, boolean jvsuffix)
+ {
+ return seq.getDisplayId(jvsuffix);
+ }
+
String printId(SequenceI seq)
{
String printId(SequenceI seq)
{
- return seq.getDisplayId(jvSuffix);
+ return printId(seq, true);
}
/**
}
/**
@@
-400,6
+419,7
@@
public abstract class AlignFile extends FileParse
return newickStrings == null ? 0 : newickStrings.size();
}
return newickStrings == null ? 0 : newickStrings.size();
}
+ @Override
public void addGroups(AlignmentI al)
{
public void addGroups(AlignmentI al)
{
@@
-409,4
+429,8
@@
public abstract class AlignFile extends FileParse
}
}
}
}
+ protected void addSequence(SequenceI seq)
+ {
+ seqs.add(seq);
+ }
}
}