/**Put sequences to a HTML file*/
@SuppressWarnings("unchecked")
public void putSequenceDB(Writer out, DefiniteSequenceDB<? extends T> sequences,
Map<?, ?> properties) {
PrintWriter pw = new PrintWriter(out);
HTMLWriter hw = new HTMLWriter(pw);
String titleString = "No title"; //$NON-NLS-1$
List<String> props = new ArrayList<String>();
//Go through properties
if (properties != null) {
for (Iterator<?> i = properties.entrySet().iterator(); i.hasNext(); ) {
Map.Entry e = (Map.Entry) i.next();
String keyString = e.getKey().toString();
String valueString = e.getValue().toString();
if (keyString.equals(TITLE_STRING)) {
titleString = keyString;
}
else {
props.add(keyString + ": " + valueString); //$NON-NLS-1$
}
}
}
hw.printTag(HTMLWriter.HTML);
hw.printAttributeTag(HTMLWriter.HEAD,new String[] { "title" }, new String[] { titleString }); //$NON-NLS-1$
hw.printEndTag(HTMLWriter.HEAD);
hw.printTag(HTMLWriter.BODY);
for (Iterator pi = props.iterator(); pi.hasNext(); ) {
pw.println(pi.next());
}
for (Iterator si = sequences.iterator(); si.hasNext(); ) {
Object probe = si.next();
if (probe instanceof Probe) {
Probe p = (Probe) probe;
PropertyAcceptorNucleotideSequence fivePrime;
PropertyAcceptorNucleotideSequence threePrime;
try {
fivePrime = (PropertyAcceptorNucleotideSequence) p.getTSSPair().getSequence(TSSPair.KEY_FIVE_PRIME);
}
catch (ClusterException e) {
fivePrime = null;
}
try {
threePrime = (PropertyAcceptorNucleotideSequence) p.getTSSPair().getSequence(TSSPair.KEY_THREE_PRIME);
}
catch (ClusterException e) {
threePrime = null;
}
hw.printEnclosed(p.getName(), HTMLWriter.H4);
hw.println(Messages.getString("HTMLOutputFormat.ID") + p.getID()); //$NON-NLS-1$
String seqstr = p.seqString();
//String seq = "";
int index = 0;
int width = 60;
while (index <= seqstr.length() - width) {
hw.printEnclosed(seqstr.substring(index, index += width), HTMLWriter.TT);
}
hw.printEnclosed(seqstr.substring(index), HTMLWriter.TT);
hw.printTag(HTMLWriter.BR);
hw.println(p.getTarget() == null ? Messages.getString("HTMLOutputFormat.NO_TARGET") : //$NON-NLS-1$
Messages.getString("HTMLOutputFormat.TARGET") + p.getTarget().getID()); //$NON-NLS-1$
hw.printEnclosed(Messages.getString("HTMLOutputFormat.BLOCKS"), HTMLWriter.H5); //$NON-NLS-1$
for (int i = 1; i <= p.getSequenceCount(); i++) {
hw.println(p.getSequence(i).getID() + ": " + //$NON-NLS-1$
p.getSequence(i).seqString());
}
hw.println(Messages.getString("HTMLOutputFormat.HYB_TEMPS_5") + //$NON-NLS-1$
tempFormat.format(fivePrime == null ? 0 : ProbeMakerPropertyUtils.getHybridizationTemp(fivePrime)) +
Messages.getString("HTMLOutputFormat.HYB_TEMPS_3") + //$NON-NLS-1$
tempFormat.format(threePrime == null ? 0 : ProbeMakerPropertyUtils.getHybridizationTemp(threePrime)));
hw.printEnclosed(Messages.getString("HTMLOutputFormat.MESSAGES"), HTMLWriter.H5); //$NON-NLS-1$
hw.printTag(HTMLWriter.UL);
for (Iterator i = ProbeMakerPropertyUtils.getAllMessages(p).iterator(); i.hasNext(); ) {
hw.printEnclosed(i.next().toString(), HTMLWriter.LI);
}
hw.printEndTag(HTMLWriter.UL);
}
else {
throw new IllegalArgumentException("Output sequence is not a Probe object"); //$NON-NLS-1$
}
}
hw.printEndTag(HTMLWriter.BODY);
hw.printEndTag(HTMLWriter.HTML);
}