2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.datamodel.ContactMatrix;
24 import jalview.datamodel.SequenceI;
26 import java.io.IOException;
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
33 * A file parser for contact prediction files.
35 * An example file is the following
45 public class PContactPredictionFile extends AlignFile
47 protected static final String CONTACT_PREDICTION = "CONTACT_PREDICTION";
49 public PContactPredictionFile(String inFile, DataSourceType fileSourceType)
52 super(inFile, fileSourceType);
56 public PContactPredictionFile(FileParse source) throws IOException
63 List<ContactMatrix> models = new ArrayList<ContactMatrix>();
65 public List<ContactMatrix> getContactMatrices()
72 * for a contact prediction
74 * alignment for target sequence
75 * contact matrix for sequence
76 * models generated that fit matrix
80 * TODO: create annotation rows from contact matrices.
82 * @see jalview.io.AlignFile#parse()
85 public void parse() throws IOException
89 * stash any header lines if we've been given a CASP-RR file
91 Map<String, String> header = new HashMap<String, String>();
92 ContactMatrix cm = null;
94 while ((line = nextLine()) != null)
97 double strength = Float.NaN;
98 String parts[] = line.split("\\s+");
100 // check for header tokens in parts[0]
102 // others - stash details
103 // MODEL - start a new matrix
106 if (parts.length == 3) // and all are integers
111 cm = new ContactMatrix(true) {
113 public String getType()
115 return CONTACT_PREDICTION;
118 public int getHeight()
120 // TODO Auto-generated method stub
121 // return maximum contact height
124 public int getWidth()
126 // TODO Auto-generated method stub
127 // return total number of residues with contacts
136 left = Integer.parseInt(parts[0]);
137 right = Integer.parseInt(parts[1]);
138 strength = Double.parseDouble(parts[2]);
139 } catch (Exception x)
142 errormessage = "Couldn't process line: "
143 + x.getLocalizedMessage() + "\n" + line;
146 cm.addContact(left, right, (float) strength);
150 throw(new Error("Not Implemented yet."));
154 public String print(SequenceI[] sqs, boolean jvsuffix)
156 // TODO Auto-generated method stub