import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GeneLocus;
import jalview.datamodel.GraphLine;
+import jalview.datamodel.GroupSet;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Point;
import jalview.datamodel.RnaViewerModel;
{
for (BitSet gp: cm.getGroups())
{
- BigInteger val = new BigInteger(gp.toByteArray());
- xmlmat.getGroups().add(val.toString());
+ xmlmat.getGroups().add(stringifyBitset(gp));
}
}
if (cm.hasTree())
}
+ private String stringifyBitset(BitSet gp) {
+ StringBuilder sb = new StringBuilder();
+ for (long val:gp.toLongArray())
+ {
+ if (sb.length()>0) {
+ sb.append(",");
+ }
+ sb.append(val);
+ }
+ return sb.toString();
+ }
+ private BitSet deStringifyBitset(String stringified) {
+ if ("".equals(stringified) || stringified==null)
+ {
+ return new BitSet();
+ }
+ String[] longvals = stringified.split(",");
+ long[] newlongvals = new long[longvals.length];
+ for (int lv=0;lv<longvals.length;lv++)
+ {
+ try {
+ newlongvals[lv]=Long.valueOf(longvals[lv]);
+ } catch (Exception x)
+ {
+ errorMessage+="Couldn't destringify bitset from: '"+stringified+"'";
+ newlongvals[lv]=0;
+ }
+ }
+ return BitSet.valueOf(newlongvals);
+
+
+ }
private CalcIdParam createCalcIdParam(String calcId, AlignViewport av)
{
AutoCalcSetting settings = av.getCalcIdSettingsFor(calcId);
mapping = new jalview.util.MapList(fr, fto, m.getMapFromUnit().intValue(),m.getMapToUnit().intValue());
}
- PAEContactMatrix newpae = new PAEContactMatrix(
- jaa.sequenceRef, mapping, elements);
List<BitSet> newgroups=new ArrayList<BitSet>();
if (xmlmat.getGroups().size()>0)
{
for (String sgroup:xmlmat.getGroups())
{
- try {
- BigInteger group = new BigInteger(sgroup);
- newgroups.add(BitSet.valueOf(group.toByteArray()));
- } catch (NumberFormatException nfe)
- {
- Console.error("Problem parsing groups for a contact matrix (\""+sgroup+"\"",nfe);
- }
+ newgroups.add(deStringifyBitset(sgroup));
}
}
String nwk=xmlmat.getNewick().size()>0 ? xmlmat.getNewick().get(0):null;
String treeMethod = xmlmat.getTreeMethod();
double thresh = xmlmat.getCutHeight()!=null ? xmlmat.getCutHeight() : 0;
- newpae.restoreGroups(newgroups, treeMethod, nwk, thresh);
+ GroupSet grpset = new GroupSet();
+ grpset.restoreGroups(newgroups, treeMethod, nwk, thresh);
+ PAEContactMatrix newpae = new PAEContactMatrix(
+ jaa.sequenceRef, mapping, elements,grpset);
jaa.sequenceRef.addContactListFor(jaa, newpae);
}
}