for (int c = 0; c < cm.getWidth(); c++)
{
ContactListI cl = cm.getContactList(c);
+ long lastsb=-1;
if (cl != null)
{
for (int h = 0; h <= cl.getContactHeight(); h++)
{
if (sb.length() > 0)
{
- sb.append('\t');
+ if (sb.length()-lastsb>320)
+ {
+ // newline
+ sb.append('\n');
+ lastsb=sb.length();
+ } else {
+ sb.append('\t');
+ }
}
sb.append(cl.getContactAt(h));
}
int rows)
{
float[][] vals = new float[cols][rows];
- StringTokenizer tabsep = new StringTokenizer(values, "" + '\t');
+ StringTokenizer tabsep = new StringTokenizer(values, "" + '\t'+'\n');
int c = 0, r = 0;
while (tabsep.hasMoreTokens())
{
import jalview.datamodel.Mapping;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
+import jalview.datamodel.Sequence;
import jalview.datamodel.Sequence.DBModList;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceFeature;
}
@Test(groups = { "Functional" })
+ public void testMatrixToFloatsAndBack()
+ {
+ int imax=2000;
+ int i=imax;
+ SequenceI sq = new Sequence("dummy","SEQ");
+ while (sq.getLength()<i)
+ {
+ sq.setSequence(sq.getSequenceAsString()+'Q');
+ }
+ float[][] paevals = new float[i][i];
+ for (i = imax - 1; i >= 0; i--)
+ {
+ for (int j = 0; j <= i; j++)
+ {
+ paevals[i][j] = ((i - j < 2)
+ || ((i > 1 && i < 5) && (j > 1 && i < 5))) ? 1 : 0f;
+ paevals[j][i] = -paevals[i][j];
+ }
+ }
+ PAEContactMatrix dummyMat = new PAEContactMatrix(sq, paevals);
+ String content = ContactMatrix.contactToFloatString(dummyMat);
+ Assert.assertTrue(content.contains("\t1.")); // at least one element must be
+ // 1
+ float[][] vals = ContactMatrix.fromFloatStringToContacts(content,
+ sq.getLength(), sq.getLength());
+ assertEquals(vals[3][4], paevals[3][4]);
+ assertEquals(vals[4][3], paevals[4][3]);
+
+ // test recovery
+ for (i=0;i<imax;i++)
+ {
+ for (int j=0;j<imax;j++)
+ {
+ assertEquals(vals[i][j],paevals[i][j]);
+ }
+ }
+ }
+ @Test(groups = { "Functional" })
public void testPAEsaveRestore() throws Exception
{
Desktop.instance.closeAll_actionPerformed(null);