X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FContactMatrix.java;h=b8593d842fd8474487f96ae14e3fe4b6dea82e26;hb=HEAD;hp=32fa5b1776f9f2e41e7180cefba0b5f1d16223f0;hpb=01dd60b282ea075d333a5a875a00906b80e6ec69;p=jalview.git diff --git a/src/jalview/datamodel/ContactMatrix.java b/src/jalview/datamodel/ContactMatrix.java index 32fa5b1..b8593d8 100644 --- a/src/jalview/datamodel/ContactMatrix.java +++ b/src/jalview/datamodel/ContactMatrix.java @@ -1,3 +1,23 @@ +/* + * 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.datamodel; import java.util.ArrayList; @@ -6,7 +26,8 @@ import java.util.StringTokenizer; import jalview.bin.Console; -public abstract class ContactMatrix extends GroupSetHolder implements ContactMatrixI +public abstract class ContactMatrix extends GroupSetHolder + implements ContactMatrixI { /** * are contacts reflexive ? @@ -112,9 +133,10 @@ public abstract class ContactMatrix extends GroupSetHolder implements ContactMat } }); } + private Float getFloatElementAt(int column, int p) { - + List clist; Float cl = null; if (symmetric) @@ -137,16 +159,18 @@ public abstract class ContactMatrix extends GroupSetHolder implements ContactMat } return cl; } + @Override public double getElementAt(int column, int row) { Float cl = getFloatElementAt(column, row); - if (cl!=null) + if (cl != null) { return cl; } - throw(new RuntimeException("Out of Bounds "+column+","+row)); + throw (new RuntimeException("Out of Bounds " + column + "," + row)); } + @Override public float getMin() { @@ -170,19 +194,30 @@ public abstract class ContactMatrix extends GroupSetHolder implements ContactMat { return "Contact Matrix"; } + public static String contactToFloatString(ContactMatrixI cm) { StringBuilder sb = new StringBuilder(); 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)); } @@ -195,7 +230,7 @@ public abstract class ContactMatrix extends GroupSetHolder implements ContactMat 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()) {