Console.debug("Downloading pae from " + paeURL + " to " + pae.toString()
+ "");
UrlDownloadClient.download(paeURL, pae);
- addAlphaFoldPAE(pdbAlignment, pae);
+ addAlphaFoldPAE(pdbAlignment, pae, 0, null);
}
- public static void addAlphaFoldPAE(AlignmentI pdbAlignment, File pae)
+ public static void addAlphaFoldPAE(AlignmentI pdbAlignment, File pae,
+ int index, String seqId)
{
FileInputStream pae_input = null;
try
try
{
- if (!importPaeJSONAsContactMatrix(pdbAlignment, pae_input))
+ if (!importPaeJSONAsContactMatrix(pdbAlignment, pae_input, index,
+ seqId))
{
Console.warn("Could not import contact matrix from '"
+ pae.getAbsolutePath() + "'");
AlignmentI pdbAlignment, InputStream pae_input)
throws IOException, ParseException
{
+ return importPaeJSONAsContactMatrix(pdbAlignment, pae_input, 0, null);
+ }
+
+ public static boolean importPaeJSONAsContactMatrix(
+ AlignmentI pdbAlignment, InputStream pae_input, int index,
+ String seqId) throws IOException, ParseException
+ {
List<Object> pae_obj = (List<Object>) Platform.parseJSON(pae_input);
if (pae_obj == null)
{
+ Console.debug("JSON file did not parse properly.");
return false;
}
- ContactMatrixI matrix = new PAEContactMatrix(
- pdbAlignment.getSequenceAt(0),
+ SequenceI sequence = null;
+ /* debugging */
+ SequenceI[] seqs = pdbAlignment.getSequencesArray();
+ if (seqs == null)
+ Console.debug("******* sequences is null");
+ else
+ {
+ for (int i = 0; i < seqs.length; i++)
+ {
+ SequenceI s = seqs[i];
+ Console.debug("******* sequences[" + i + "]='" + s.getName() + "'");
+ }
+ }
+ /* end debug */
+ if (seqId == null)
+ {
+ int seqToGet = index > 0 ? index : 0;
+ sequence = pdbAlignment.getSequenceAt(seqToGet);
+ Console.debug("***** Got sequence at index " + seqToGet + ": "
+ + (sequence == null ? null : sequence.getName()));
+ }
+ else
+ {
+ Console.debug("***** Looking for sequence with id '" + seqId + "'");
+
+ SequenceI[] sequences = pdbAlignment.findSequenceMatch(seqId);
+ if (sequences == null || sequences.length < 1)
+ {
+ Console.warn("Could not find sequence with id '" + seqId
+ + "' to attach pAE matrix to. Ignoring matrix.");
+ return false;
+ }
+ else
+ {
+ sequence = sequences[0]; // just use the first sequence with this seqId
+ }
+ }
+ ContactMatrixI matrix = new PAEContactMatrix(sequence,
(Map<String, Object>) pae_obj.get(0));
- AlignmentAnnotation cmannot = pdbAlignment.getSequenceAt(0)
- .addContactList(matrix);
+ AlignmentAnnotation cmannot = sequence.addContactList(matrix);
pdbAlignment.addAnnotation(cmannot);
return true;
}