/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.io;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.util.UrlLink;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
/**
* generate HTML reports for a sequence
*
* @author jimp
*/
public class SequenceAnnotationReport
{
final String linkImageURL;
public SequenceAnnotationReport(String linkImageURL)
{
this.linkImageURL = linkImageURL;
}
/**
* appends the features at rpos to the given stringbuffer ready for display in
* a tooltip
*
* @param tooltipText2
* @param linkImageURL
* @param rpos
* @param features
* TODO refactor to Jalview 'utilities' somehow.
*/
public void appendFeatures(final StringBuffer tooltipText2, int rpos,
List features)
{
appendFeatures(tooltipText2, rpos, features, null);
}
public void appendFeatures(final StringBuffer tooltipText2, int rpos,
List features, Hashtable minmax)
{
String tmpString;
if (features != null)
{
for (SequenceFeature feature:features)
{
if (feature.getType().equals("disulfide bond"))
{
if (feature.getBegin() == rpos
|| feature.getEnd() == rpos)
{
if (tooltipText2.length() > 6)
{
tooltipText2.append("
");
}
tooltipText2.append("disulfide bond " + feature.getBegin()
+ ":" + feature.getEnd());
}
}
else
{
if (tooltipText2.length() > 6)
{
tooltipText2.append("
");
}
// TODO: remove this hack to display link only features
boolean linkOnly = feature.getValue("linkonly") != null;
if (!linkOnly)
{
tooltipText2.append(feature.getType() + " ");
if (rpos != 0)
{
// we are marking a positional feature
tooltipText2.append(feature.begin);
}
if (feature.begin != feature.end)
{
tooltipText2.append(" " + feature.end);
}
if (feature.getDescription() != null
&& !feature.description.equals(feature
.getType()))
{
tmpString = feature.getDescription();
String tmp2up = tmpString.toUpperCase();
int startTag = tmp2up.indexOf("");
if (startTag > -1)
{
tmpString = tmpString.substring(startTag + 6);
tmp2up = tmp2up.substring(startTag + 6);
}
int endTag = tmp2up.indexOf("");
if (endTag > -1)
{
tmpString = tmpString.substring(0, endTag);
tmp2up = tmp2up.substring(0, endTag);
}
endTag = tmp2up.indexOf("