import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.util.MessageManager;
alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex(
hiddenCols);
}
- String output = new FormatAdapter().formatSequences("Fasta", seqs,
- omitHidden, alignmentStartEnd);
+ String output = new FormatAdapter().formatSequences(FileFormat.Fasta,
+ seqs, omitHidden, alignmentStartEnd);
Toolkit.getDefaultToolkit().getSystemClipboard()
.setContents(new StringSelection(output), Desktop.instance);
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.io.FileFormat;
import jalview.io.FormatAdapter;
import jalview.io.SequenceAnnotationReport;
import jalview.schemes.AnnotationColourGradient;
// or we simply trust the user wants
// wysiwig behaviour
- cap.setText(new FormatAdapter(ap).formatSequences(e.getActionCommand(),
- ap, true));
+ FileFormat fileFormat = FileFormat.forName(e.getActionCommand());
+ cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true));
}
public void sequenceFeature_actionPerformed()
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceI;
public class AMSAFile extends jalview.io.FastaFile
{
*
* @return DOCUMENT ME!
*/
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- super.print(getSeqsAsArray());
+ super.print(sqs, jvsuffix);
AlignmentAnnotation aa;
if (al.getAlignmentAnnotation() != null)
long end;
- boolean jvSuffix = true;
-
private boolean parseCalled;
/**
initData();
}
+ public AlignFile(SequenceI[] seqs)
+ {
+ this();
+ setSeqs(seqs);
+ }
+
/**
* Constructor which parses the data from a file of some specified type.
*
public abstract void parse() throws IOException;
/**
- * Print out in alignment file format the Sequences in the seqs Vector.
- */
- @Override
- public abstract String print();
-
- @Override
- public void addJVSuffix(boolean b)
- {
- jvSuffix = b;
- }
-
- /**
* A general parser for ids.
*
* @String id Id to be parsed
* Creates the output id. Adds prefix Uniprot format source|id And suffix
* Jalview /start-end
*
+ * @param jvsuffix
+ *
* @String id Id to be parsed
*/
- String printId(SequenceI seq)
+ String printId(SequenceI seq, boolean jvsuffix)
{
- return seq.getDisplayId(jvSuffix);
+ return seq.getDisplayId(jvsuffix);
}
/**
void setNewlineString(String newline);
- void addJVSuffix(boolean jvsuffix);
-
void setExportSettings(AlignExportSettingI exportSettings);
void configureForView(AlignmentViewPanel viewpanel);
void setSeqs(SequenceI[] sequencesArray);
- String print();
+ String print(SequenceI[] seqs, boolean jvsuffix);
boolean hasWarningMessage();
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
+import jalview.datamodel.SequenceI;
import jalview.structure.StructureImportSettings;
import java.io.File;
public static final String[] READABLE_EXTENSIONS = new String[] {
"fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
"sto,stk", "xml,rnaml", "phy", "json",
- ".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT, "cif" };
+ ".gff2,gff3", "jar,jvp", "html", "cif" };
/**
* List of readable formats by application in order corresponding to
}
/**
- * check that this format is valid for reading
- *
- * @param format
- * a format string to be compared with READABLE_FORMATS
- * @return true if format is readable
- */
- public static final boolean isValidFormat(String format)
- {
- return isValidFormat(format, false);
- }
-
- /**
- * validate format is valid for IO
- *
- * @param format
- * a format string to be compared with either READABLE_FORMATS or
- * WRITEABLE_FORMATS
- * @param forwriting
- * when true, format is checked for containment in WRITEABLE_FORMATS
- * @return true if format is valid
- */
- public static final boolean isValidFormat(String format,
- boolean forwriting)
- {
- if (format == null)
- {
- return false;
- }
- boolean valid = false;
- String[] format_list = (forwriting) ? WRITEABLE_FORMATS
- : READABLE_FORMATS;
- for (String element : format_list)
- {
- if (element.equalsIgnoreCase(format))
- {
- return true;
- }
- }
-
- return valid;
- }
-
- /**
* Constructs the correct filetype parser for a characterised datasource
*
* @param inFile
AlignmentFileI afile = format.getAlignmentFile();
afile.setNewlineString(newline);
- afile.addJVSuffix(jvsuffix);
afile.setExportSettings(exportSettings);
afile.configureForView(viewpanel);
// check whether we were given a specific alignment to export, rather than
// the one in the viewpanel
+ SequenceI[] seqs = null;
if (viewpanel == null || viewpanel.getAlignment() == null
|| viewpanel.getAlignment() != alignment)
{
- afile.setSeqs(alignment.getSequencesArray());
+ seqs = alignment.getSequencesArray();
}
else
{
- afile.setSeqs(viewpanel.getAlignment().getSequencesArray());
+ seqs = viewpanel.getAlignment().getSequencesArray();
}
- String afileresp = afile.print();
+ String afileresp = afile.print(seqs, jvsuffix);
if (afile.hasWarningMessage())
{
System.err.println("Warning raised when writing as " + format
/**
* DOCUMENT ME!
*
- * @return DOCUMENT ME!
- */
- @Override
- public String print()
- {
- return print(getSeqsAsArray());
- }
-
- /**
- * DOCUMENT ME!
- *
* @param s
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
- public String print(SequenceI[] s)
+ @Override
+ public String print(SequenceI[] s, boolean jvsuffix)
{
StringBuffer out = new StringBuffer();
/**
while ((i < s.length) && (s[i] != null))
{
- out.append(">" + printId(s[i]));
+ out.append(">" + printId(s[i], jvsuffix));
if (s[i].getDescription() != null)
{
out.append(" " + s[i].getDescription());
}
@Override
- public String print()
- {
- return print(getSeqsAsArray());
- // TODO: locaRNA style aln output
- }
-
- public String print(SequenceI[] s)
+ public String print(SequenceI[] s, boolean jvsuffix)
{
StringBuffer out = new StringBuffer("CLUSTAL" + newline + newline);
while ((i < s.length) && (s[i] != null))
{
- String tmp = printId(s[i]);
+ String tmp = printId(s[i], jvsuffix);
if (s[i].getSequence().length > max)
{
while ((j < s.length) && (s[j] != null))
{
- out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " "));
+ out.append(new Format("%-" + maxid + "s").form(printId(s[j],
+ jvsuffix) + " "));
int start = i * len;
int end = start + len;
*/
package jalview.io;
+import jalview.datamodel.SequenceI;
+
import java.io.IOException;
/**
public class DBRefFile extends AlignFile
{
+ @Override
public void parse() throws IOException
{
// TODO Auto-generated method stub
}
- public String print()
+ @Override
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
// TODO Auto-generated method stub
return null;
super(source);
}
+ public FastaFile(SequenceI[] seqs)
+ {
+ super(seqs);
+ }
+
/**
* DOCUMENT ME!
*
}
}
- /**
- * DOCUMENT ME!
- *
- * @param s
- * DOCUMENT ME!
- * @param len
- * DOCUMENT ME!
- * @param gaps
- * DOCUMENT ME!
- * @param displayId
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String print(SequenceI[] s)
+ @Override
+ public String print(SequenceI[] s, boolean jvsuffix)
{
out = new StringBuffer();
int i = 0;
while ((i < s.length) && (s[i] != null))
{
- out.append(">" + printId(s[i]));
+ out.append(">" + printId(s[i], jvsuffix));
if (s[i].getDescription() != null)
{
out.append(" " + s[i].getDescription());
return out.toString();
}
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- @Override
- public String print()
- {
- return print(getSeqsAsArray());
- }
}
* @return error message
*/
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- return "Use printGffFormat() or printJalviewFormat()";
+ System.out.println("Use printGffFormat() or printJalviewFormat()");
+ return null;
}
/**
import jalview.structure.StructureImportSettings;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
public enum FileFormat implements FileFormatI
{
- Fasta
+ Fasta("FASTA", "fa, fasta, mfa, fastq", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
return new FastaFile();
}
},
- Pfam
+ Pfam("PFAM", "pfam", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
return new PfamFile();
}
},
- Stockholm
+ Stockholm("STH", "sto,stk", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- SimpleBlast
- {
- @Override
- public AlignmentFileI getAlignmentFile(String inFile,
- DataSourceType sourceType) throws IOException
- {
- return new SimpleBlastFile(inFile, sourceType);
- }
- @Override
- public AlignmentFileI getAlignmentFile(FileParse source)
- throws IOException
- {
- return new SimpleBlastFile(source);
- }
-
- @Override
- public AlignmentFileI getAlignmentFile()
- {
- return new SimpleBlastFile();
- }
- },
-
- PIR
+ PIR("PIR", "pir", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
return new PIRFile();
}
},
- BLC
+ BLC("BLC", "BLC", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
{
return new BLCFile();
}
-
},
- Html
+ Html("HTML", "html", true, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- Rnaml
+ Rnaml("RNAML", "xml,rnaml", true, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- Json
+ Json("JSON","json", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- Pileup
+ Pileup("PileUp", "?", false, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- MSF
+ MSF("MSF", "msf", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- Clustal
+ Clustal("CLUSTAL", "aln", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
{
return new ClustalFile();
}
-
},
- Phylip
+ Phylip("PHYLIP", "phy", true, true)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
{
return new PhylipFile();
}
-
},
- Jnet
+ Jnet("JnetFile", "", false, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
}
},
- Features
+ Features("GFF or Jalview features", "gff2,gff3", false, false)
{
@Override
public AlignmentFileI getAlignmentFile(String inFile,
return new FeaturesFile();
}
},
- PDB
+ PDB("PDB", "", false, false)
{
@Override
{
return new JmolParser(); // todo or null?
}
-
},
- MMCif
+ MMCif("mmCIF", "cif", false, false)
{
@Override
return new JmolParser(); // todo or null?
}
},
- Jalview
+ Jalview("Jalview", "jar,jvp", true, false)
{
@Override
}
};
+ /**
+ * A lookup map of enums by upper-cased name
+ */
+ private static Map<String, FileFormat> names;
+ static
+ {
+ names = new HashMap<String, FileFormat>();
+ for (FileFormat format : FileFormat.values())
+ {
+ names.put(format.toString().toUpperCase(), format);
+ }
+ }
+
+ private boolean writable;
+
+ private boolean readable;
+
+ private String extensions;
+
+ private String name;
+
@Override
public boolean isComplexAlignFile()
{
{
return toString();
}
+
+ /**
+ * Returns the file format with the given name, or null if format is null or
+ * invalid. Unlike valueOf(), this is not case-sensitive, to be kind to
+ * writers of javascript.
+ *
+ * @param format
+ * @return
+ */
+ public static FileFormatI forName(String format)
+ {
+ // or could store format.getShortDescription().toUpperCase()
+ // in order to decouple 'given name' from enum name
+ return format == null ? null : names.get(format.toUpperCase());
+ }
+
+ @Override
+ public boolean isReadable()
+ {
+ return readable;
+ }
+
+ @Override
+ public boolean isWritable()
+ {
+ return writable;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param shortName
+ * @param extensions
+ * comma-separated list of file extensions associated with the format
+ * @param isReadable
+ * @param isWritable
+ */
+ private FileFormat(String shortName, String extensions,
+ boolean isReadable, boolean isWritable)
+ {
+ this.name = shortName;
+ this.extensions = extensions;
+ this.readable = isReadable;
+ this.writable = isWritable;
+ }
+
+ @Override
+ public String getExtensions()
+ {
+ return extensions;
+ }
}
String getShortDescription();
+ /**
+ * Returns a comma-separated list of file extensions associated with the
+ * format
+ *
+ * @return
+ */
+ String getExtensions();
+
+ boolean isReadable();
+
+ boolean isWritable();
}
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
+import jalview.util.Comparison;
import java.io.IOException;
}
}
- public String formatSequences(String format, SequenceI[] seqs,
+ public String formatSequences(FileFormatI format, SequenceI[] seqs,
String[] omitHiddenColumns, int[] exportRange)
{
startIndex = startEnd[0];
endIndex = startEnd[1];
// get first non-gaped residue start position
- while (jalview.util.Comparison.isGap(seqs[i]
+ while (Comparison.isGap(seqs[i]
.getCharAt(startIndex)) && startIndex < endIndex)
{
startIndex++;
}
// get last non-gaped residue end position
- while (jalview.util.Comparison.isGap(seqs[i].getCharAt(endIndex))
+ while (Comparison.isGap(seqs[i].getCharAt(endIndex))
&& endIndex > startIndex)
{
endIndex--;
*
*
* @param format
- * Format string as givien in the AppletFormatAdaptor list (exact
- * match to name of class implementing file io for that format)
* @param seqs
* vector of sequences to write
*
* @return String containing sequences in desired format
*/
- public String formatSequences(String format, SequenceI[] seqs)
+ public String formatSequences(FileFormatI format, SequenceI[] seqs)
{
+ //
+ // try
+ // {
+ boolean withSuffix = getCacheSuffixDefault(format);
+ return format.getAlignmentFile().print(seqs, withSuffix);
+ // null;
+ //
+ // if (format.equalsIgnoreCase("FASTA"))
+ // {
+ // afile = new FastaFile();
+ // afile.addJVSuffix(jalview.bin.Cache.getDefault("FASTA_JVSUFFIX",
+ // true));
+ // }
+ // else if (format.equalsIgnoreCase("MSF"))
+ // {
+ // afile = new MSFfile();
+ // afile.addJVSuffix(jalview.bin.Cache
+ // .getDefault("MSF_JVSUFFIX", true));
+ // }
+ // else if (format.equalsIgnoreCase("PileUp"))
+ // {
+ // afile = new PileUpfile();
+ // afile.addJVSuffix(jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX",
+ // true));
+ // }
+ // else if (format.equalsIgnoreCase("CLUSTAL"))
+ // {
+ // afile = new ClustalFile();
+ // afile.addJVSuffix(jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX",
+ // true));
+ // }
+ // else if (format.equalsIgnoreCase("BLC"))
+ // {
+ // afile = new BLCFile();
+ // afile.addJVSuffix(jalview.bin.Cache
+ // .getDefault("BLC_JVSUFFIX", true));
+ // }
+ // else if (format.equalsIgnoreCase("PIR"))
+ // {
+ // afile = new PIRFile();
+ // afile.addJVSuffix(jalview.bin.Cache
+ // .getDefault("PIR_JVSUFFIX", true));
+ // }
+ // else if (format.equalsIgnoreCase("PFAM"))
+ // {
+ // afile = new PfamFile();
+ // afile.addJVSuffix(jalview.bin.Cache.getDefault("PFAM_JVSUFFIX",
+ // true));
+ // }
+ // /*
+ // * amsa is not supported by this function - it requires an alignment
+ // * rather than a sequence vector else if
+ // (format.equalsIgnoreCase("AMSA"))
+ // * { afile = new AMSAFile(); afile.addJVSuffix(
+ // * jalview.bin.Cache.getDefault("AMSA_JVSUFFIX", true)); }
+ // */
- try
- {
- AlignFile afile = null;
-
- if (format.equalsIgnoreCase("FASTA"))
- {
- afile = new FastaFile();
- afile.addJVSuffix(jalview.bin.Cache.getDefault("FASTA_JVSUFFIX",
- true));
- }
- else if (format.equalsIgnoreCase("MSF"))
- {
- afile = new MSFfile();
- afile.addJVSuffix(jalview.bin.Cache
- .getDefault("MSF_JVSUFFIX", true));
- }
- else if (format.equalsIgnoreCase("PileUp"))
- {
- afile = new PileUpfile();
- afile.addJVSuffix(jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX",
- true));
- }
- else if (format.equalsIgnoreCase("CLUSTAL"))
- {
- afile = new ClustalFile();
- afile.addJVSuffix(jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX",
- true));
- }
- else if (format.equalsIgnoreCase("BLC"))
- {
- afile = new BLCFile();
- afile.addJVSuffix(jalview.bin.Cache
- .getDefault("BLC_JVSUFFIX", true));
- }
- else if (format.equalsIgnoreCase("PIR"))
- {
- afile = new PIRFile();
- afile.addJVSuffix(jalview.bin.Cache
- .getDefault("PIR_JVSUFFIX", true));
- }
- else if (format.equalsIgnoreCase("PFAM"))
- {
- afile = new PfamFile();
- afile.addJVSuffix(jalview.bin.Cache.getDefault("PFAM_JVSUFFIX",
- true));
- }
- /*
- * amsa is not supported by this function - it requires an alignment
- * rather than a sequence vector else if (format.equalsIgnoreCase("AMSA"))
- * { afile = new AMSAFile(); afile.addJVSuffix(
- * jalview.bin.Cache.getDefault("AMSA_JVSUFFIX", true)); }
- */
-
- afile.setSeqs(seqs);
- String afileresp = afile.print();
- if (afile.hasWarningMessage())
- {
- System.err.println("Warning raised when writing as " + format
- + " : " + afile.getWarningMessage());
- }
- return afileresp;
- } catch (Exception e)
- {
- System.err.println("Failed to write alignment as a '" + format
- + "' file\n");
- e.printStackTrace();
- }
-
- return null;
+// afile.setSeqs(seqs);
+// String afileresp = afile.print();
+// if (afile.hasWarningMessage())
+// {
+// System.err.println("Warning raised when writing as " + format
+// + " : " + afile.getWarningMessage());
+// }
+// return afileresp;
+// } catch (Exception e)
+// {
+// System.err.println("Failed to write alignment as a '" + format
+// + "' file\n");
+// e.printStackTrace();
+// }
+//
+// return null;
}
public boolean getCacheSuffixDefault(FileFormatI format)
}
/**
- * validate format is valid for IO in Application. This is basically the
- * AppletFormatAdapter.isValidFormat call with additional checks for
- * Application only formats like 'Jalview'.
- *
- * @param format
- * a format string to be compared with list of readable or writable
- * formats (READABLE_FORMATS or WRITABLE_FORMATS)
- * @param forwriting
- * when true, format is checked against list of writable formats.
- * @return true if format is valid
- */
- public static final boolean isValidIOFormat(String format,
- boolean forwriting)
- {
- if (format.equalsIgnoreCase("jalview"))
- {
- return true;
- }
- return AppletFormatAdapter.isValidFormat(format, forwriting);
- }
-
- /**
* Create a flat file representation of a given view or selected region of a
* view
*
}
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
throw new UnsupportedOperationException(
"Print method of HtmlFile is not supported!");
* @return String
*/
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
return "Not Supported";
}
}
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
String jsonOutput = null;
try
}
int count = 0;
- for (SequenceI seq : seqs)
+ for (SequenceI seq : sqs)
{
StringBuilder name = new StringBuilder();
name.append(seq.getName()).append("/").append(seq.getStart())
if (exportSettings.isExportFeatures())
{
jsonAlignmentPojo
- .setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr));
+ .setSeqFeatures(sequenceFeatureToJsonPojo(sqs, fr));
}
if (exportSettings.isExportGroups() && seqGroups != null
}
public List<SequenceFeaturesPojo> sequenceFeatureToJsonPojo(
- List<SequenceI> seqs, FeatureRenderer fr)
+ SequenceI[] sqs, FeatureRenderer fr)
{
displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed();
List<SequenceFeaturesPojo> sequenceFeaturesPojo = new ArrayList<SequenceFeaturesPojo>();
- for (SequenceI seq : seqs)
+ if (sqs == null)
+ {
+ return sequenceFeaturesPojo;
+ }
+
+ for (SequenceI seq : sqs)
{
SequenceI dataSetSequence = seq.getDatasetSequence();
SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.util.Comparison;
import jalview.util.Format;
import java.io.IOException;
return check % 10000;
}
- /**
- * DOCUMENT ME!
- *
- * @param s
- * DOCUMENT ME!
- * @param is_NA
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- public String print(SequenceI[] seqs)
+ @Override
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- boolean is_NA = jalview.util.Comparison.isNucleotide(seqs);
+ boolean is_NA = Comparison.isNucleotide(sqs);
- SequenceI[] s = new SequenceI[seqs.length];
+ SequenceI[] s = new SequenceI[sqs.length];
StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA")
+ "_MULTIPLE_ALIGNMENT 1.0");
int maxid = 0;
int i = 0;
- while ((i < seqs.length) && (seqs[i] != null))
+ while ((i < sqs.length) && (sqs[i] != null))
{
// Replace all internal gaps with . and external spaces with ~
- s[i] = new Sequence(seqs[i].getName(), seqs[i].getSequenceAsString()
- .replace('-', '.'), seqs[i].getStart(), seqs[i].getEnd());
+ s[i] = new Sequence(sqs[i].getName(), sqs[i].getSequenceAsString()
+ .replace('-', '.'), sqs[i].getStart(), sqs[i].getEnd());
StringBuffer sb = new StringBuffer();
sb.append(s[i].getSequence());
while ((i < s.length) && (s[i] != null))
{
- nameBlock[i] = new String(" Name: " + printId(s[i]) + " ");
+ nameBlock[i] = new String(" Name: " + printId(s[i], jvsuffix) + " ");
idBlock[i] = new String("Len: "
+ maxLenpad.form(s[i].getSequence().length) + " Check: "
while ((j < s.length) && (s[j] != null))
{
- String name = printId(s[j]);
+ String name = printId(s[j], jvsuffix);
out.append(new Format("%-" + maxid + "s").form(name + " "));
return out.toString();
}
-
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- @Override
- public String print()
- {
- return print(getSeqsAsArray());
- }
}
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.util.Comparison;
import java.io.IOException;
import java.util.Vector;
}
@Override
- public String print()
+ public String print(SequenceI[] s, boolean jvsuffix)
{
- return print(getSeqsAsArray());
- }
-
- public String print(SequenceI[] s)
- {
- boolean is_NA = jalview.util.Comparison.isNucleotide(s);
+ boolean is_NA = Comparison.isNucleotide(s);
int len = 72;
StringBuffer out = new StringBuffer();
int i = 0;
}
else
{
- out.append(">P1;" + printId(s[i]));
+ out.append(">P1;" + printId(s[i], jvsuffix));
out.append(newline);
if (s[i].getDescription() != null)
{
}
}
- public String print(SequenceI[] s)
+ @Override
+ public String print(SequenceI[] s, boolean jvsuffix)
{
StringBuffer out = new StringBuffer("");
while ((i < s.length) && (s[i] != null))
{
- String tmp = printId(s[i]);
+ String tmp = printId(s[i], jvsuffix);
if (s[i].getSequence().length > max)
{
while ((j < s.length) && (s[j] != null))
{
- out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " "));
+ out.append(new Format("%-" + maxid + "s")
+ .form(printId(s[j], jvsuffix) + " "));
out.append(s[j].getSequenceAsString());
out.append(newline);
return out.toString();
}
-
- @Override
- public String print()
- {
- return print(getSeqsAsArray());
- }
}
* @see {@link AlignFile#print()}
*/
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- StringBuffer sb = new StringBuffer(Integer.toString(seqs.size()));
+ StringBuffer sb = new StringBuffer(Integer.toString(sqs.length));
sb.append(" ");
// if there are no sequences, then define the number of characters as 0
sb.append(
- (seqs.size() > 0) ? Integer
- .toString(seqs.get(0).getSequence().length) : "0")
+ (sqs.length > 0) ? Integer.toString(sqs[0].getSequence().length)
+ : "0")
.append(newline);
// Due to how IO is handled, there doesn't appear to be a way to store
int numInterleavedColumns = 60;
int sequenceLength = 0;
- for (SequenceI s : seqs)
+ for (SequenceI s : sqs)
{
// ensure name is only 10 characters
// add blank line to separate this matrix from previous
sb.append(newline);
int start = i * numInterleavedColumns;
- for (SequenceI s : seqs)
+ for (SequenceI s : sqs)
{
sb.append(
s.getSequence(start, Math.min(start
super(source);
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
- @Override
- public String print()
- {
- return print(getSeqsAsArray());
- }
-
@Override
- public String print(SequenceI[] s)
+ public String print(SequenceI[] s, boolean jvsuffix)
{
StringBuffer out = new StringBuffer("PileUp");
out.append(newline);
while ((i < s.length) && (s[i] != null))
{
String seq = s[i].getSequenceAsString();
- out.append(" Name: " + printId(s[i]) + " oo Len: " + seq.length()
+ out.append(" Name: " + printId(s[i], jvsuffix) + " oo Len: "
+ + seq.length()
+ " Check: " + checksums[i] + " Weight: 1.00");
out.append(newline);
while ((j < s.length) && (s[j] != null))
{
- String name = printId(s[j]);
+ String name = printId(s[j], jvsuffix);
out.append(new Format("%-" + maxid + "s").form(name + " "));
setSeqs(seqs);
}
- public static String print(SequenceI[] s)
- {
- return "not yet implemented";
- }
-
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- System.out.print("print :");
- return print(getSeqsAsArray());
+ return "not yet implemented";
}
public ArrayList getRNA()
}
}
- public String print(SequenceI[] s)
- {
- return new String("Not Implemented.");
- }
-
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
- return print(getSeqsAsArray());
+ return new String("Not Implemented.");
}
}
return annot;
}
- public String print(SequenceI[] s)
+ @Override
+ public String print(SequenceI[] s, boolean jvsuffix)
{
+ // out.append("# STOCKHOLM 1.0");
+ // out.append(newline);
+
// find max length of id
int max = 0;
int maxid = 0;
Hashtable dataRef = null;
while ((in < s.length) && (s[in] != null))
{
- String tmp = printId(s[in]);
+ String tmp = printId(s[in], jvsuffix);
if (s[in].getSequence().length > max)
{
max = s[in].getSequence().length;
// out.append("#=GR ");
out.append(new Format("%-" + maxid + "s").form("#=GR "
- + printId(s[i]) + " " + key + " "));
+ + printId(s[i], jvsuffix) + " " + key + " "));
ann = alAnot[j].annotations;
boolean isrna = alAnot[j].isValidStruc();
String seq = "";
}
}
- out.append(new Format("%-" + maxid + "s").form(printId(s[i]) + " "));
+ out.append(new Format("%-" + maxid + "s")
+ .form(printId(s[i], jvsuffix) + " "));
out.append(s[i].getSequenceAsString());
out.append(newline);
i++;
out.append(newline);
}
}
+ // out.append("//");
+ // out.append(newline);
return out.toString();
}
return seq;
}
- @Override
- public String print()
- {
- out = new StringBuffer();
- out.append("# STOCKHOLM 1.0");
- out.append(newline);
- print(getSeqsAsArray());
-
- out.append("//");
- out.append(newline);
- return out.toString();
- }
-
private static Hashtable typeIds = null;
static
{
}
@Override
- public String print()
+ public String print(SequenceI[] sqs, boolean jvsuffix)
{
// TODO Auto-generated method stub
return "Not valid.";
import jalview.api.FeatureColourI;
import jalview.datamodel.AlignmentI;
import jalview.io.AppletFormatAdapter;
+import jalview.io.FileFormatI;
import jalview.io.FileParse;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
FileParse src = dta.getDataSource();
if (dta.getType().equals(DataProvider.JvDataType.ALIGNMENT))
{
- String fmt = null;
+ FileFormatI fmt = null;
try
{
fmt = new IdentifyFile().identify(src, false);
if (fmt != null)
{
- if (!FormatAdapter.isValidIOFormat(fmt, false))
+ // parse the alignment
+ AlignmentI al = null;
+ try
{
- errmsg = fmt;
- exerror = null;
+ al = new FormatAdapter().readFromFile(src, fmt);
+ } catch (Exception e)
+ {
+ errmsg = "Failed to parse alignment from result set";
+ exerror = e;
}
- else
+ if (al != null)
{
- // parse the alignment
- AlignmentI al = null;
- try
- {
- al = new FormatAdapter().readFromFile(src, fmt);
- } catch (Exception e)
- {
- errmsg = "Failed to parse alignment from result set";
- exerror = e;
- }
- if (al != null)
- {
- // deuniquify and construct/merge additional dataset entries if
- // necessary.
- context.addAlignment(al);
- context.updateSetModified(true);
- rslt.add(al);
- deuniquify = true;
- }
+ // deuniquify and construct/merge additional dataset entries if
+ // necessary.
+ context.addAlignment(al);
+ context.updateSetModified(true);
+ rslt.add(al);
+ deuniquify = true;
}
}
}
import jalview.io.IdentifyFile;
import jalview.io.JPredFile;
import jalview.io.JnetAnnotationMaker;
+import jalview.io.PileUpfile;
import jalview.util.Comparison;
import jalview.util.MessageManager;
import jalview.ws.AWsJob;
if (msf.length > 1)
{
msa = new vamsas.objects.simple.Msfalignment();
- jalview.io.PileUpfile pileup = new jalview.io.PileUpfile();
+ PileUpfile pileup = new PileUpfile();
msa.setMsf(pileup.print(msf));
}
}
import jalview.api.FeatureSettingsModelI;
import jalview.datamodel.AlignmentI;
+import jalview.io.DataSourceType;
+import jalview.io.FileFormatI;
import jalview.io.FormatAdapter;
import jalview.io.IdentifyFile;
protected AlignmentI parseResult(String result) throws Exception
{
AlignmentI sequences = null;
- String format = new IdentifyFile().identify(result, "Paste");
- if (FormatAdapter.isValidFormat(format))
+ FileFormatI format = new IdentifyFile().identify(result,
+ DataSourceType.PASTE);
+ if (format != null)
{
- sequences = new FormatAdapter().readFile(result.toString(), "Paste",
+ sequences = new FormatAdapter().readFile(result.toString(),
+ DataSourceType.PASTE,
format);
}
return sequences;
+ " bases with " + gapPercentage + "% gaps and "
+ changePercentage + "% mutations (random seed = " + randomSeed
+ ")");
- System.out.println(new FastaFile().print(al.getSequencesArray()));
+ System.out.println(new FastaFile().print(al.getSequencesArray(), true));
}
/**
{
AssertJUnit
.fail("Couldn't find this sequence in original input:\n"
- + new FastaFile()
- .print(new SequenceI[] { sq })
+ + new FastaFile().print(
+ new SequenceI[] { sq }, true)
+ "\n\nOriginal input:\n"
- + new FastaFile().print(pdbf.getSeqsAsArray())
- + "\n");
+ + new FastaFile().print(
+ pdbf.getSeqsAsArray(), true) + "\n");
}
}
}
{
try
{
- String aligfileout = new FormatAdapter().formatSequences("PFAM",
- al.getSequencesArray());
+ String aligfileout = FileFormat.Pfam.getAlignmentFile().print(
+ al.getSequencesArray(), true);
String anfileout = new AnnotationFile()
.printAnnotationsForAlignment(al);
assertTrue(
try
{
// what format would be appropriate for RNAalifold annotations?
- String aligfileout = new FormatAdapter().formatSequences("PFAM",
- al.getSequencesArray());
+ String aligfileout = FileFormat.Pfam.getAlignmentFile().print(
+ al.getSequencesArray(), true);
String anfileout = new AnnotationFile()
.printAnnotationsForAlignment(al);
try
{
// what format would be appropriate for RNAalifold annotations?
- String aligfileout = new FormatAdapter().formatSequences("PFAM",
- al.getSequencesArray());
+ String aligfileout = FileFormat.Pfam.getAlignmentFile().print(
+ al.getSequencesArray(), true);
String anfileout = new AnnotationFile()
.printAnnotationsForAlignment(al);