*/
package jalview.analysis;
-import java.util.Locale;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ContactMatrixI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GeneLociI;
import jalview.datamodel.IncompleteCodonException;
*/
final Iterable<AlignmentAnnotation> matchedAlignmentAnnotations = al
.findAnnotations(seq, dsann.getCalcId(), dsann.label);
- if (!matchedAlignmentAnnotations.iterator().hasNext())
+ if (matchedAlignmentAnnotations == null
+ || !matchedAlignmentAnnotations.iterator().hasNext())
{
result.add(dsann);
if (labelForCalcId != null)
startRes = selectionGroup.getStartRes();
endRes = selectionGroup.getEndRes();
}
- copyAnn.restrict(startRes, endRes);
+ copyAnn.restrict(startRes, endRes + 0);
/*
* Add to the sequence (sets copyAnn.datasetSequence), unless the
*/
if (!seq.hasAnnotation(ann))
{
+ ContactMatrixI cm = seq.getDatasetSequence()
+ .getContactMatrixFor(ann);
+ if (cm != null)
+ {
+ seq.addContactListFor(copyAnn, cm);
+ }
seq.addAlignmentAnnotation(copyAnn);
}
// adjust for gaps
copyAnn.visible = true;
}
}
+
}
/**
public Iterable<AlignmentAnnotation> findAnnotations(SequenceI seq,
String calcId, String label)
{
- return AlignmentAnnotation.findAnnotations(
- Arrays.asList(getAlignmentAnnotation()), seq, calcId, label);
+ return annotations == null ? null
+ : AlignmentAnnotation.findAnnotations(
+ Arrays.asList(getAlignmentAnnotation()), seq, calcId,
+ label);
}
@Override
}
@Override
+ public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+ {
+ return cmholder.getContactMatrixFor(ann);
+ }
+
+ @Override
public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
{
- return cmholder.getContactListFor(_aa, column);
+ ContactListI cl = cmholder.getContactListFor(_aa, column);
+ if (cl == null && _aa.groupRef != null)
+ {
+ cl = _aa.groupRef.getContactListFor(_aa, column);
+ }
+ if (cl == null && _aa.sequenceRef != null)
+ {
+ cl = _aa.sequenceRef.getContactListFor(_aa, column);
+ if (cl == null && _aa.sequenceRef.getDatasetSequence() != null)
+ {
+ _aa.sequenceRef.getDatasetSequence().getContactListFor(_aa, column);
+ }
+ }
+ return cl;
}
@Override
addAnnotation(aa);
return aa;
}
+
+ @Override
+ public void addContactListFor(AlignmentAnnotation annotation,
+ ContactMatrixI cm)
+ {
+ cmholder.addContactListFor(annotation, cm);
+
+ }
}
}
return aa;
}
+
+ @Override
+ public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+ {
+ return contactmaps == null ? null : contactmaps.get(ann.annotationId);
+ }
+
+ @Override
+ public void addContactListFor(AlignmentAnnotation annotation,
+ ContactMatrixI cm)
+ {
+ contactmaps.put(annotation.annotationId, cm);
+ }
}
Collection<ContactMatrixI> getContactMaps();
+ public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann);
+
+ void addContactListFor(AlignmentAnnotation annotation, ContactMatrixI cm);
+
}
_aa.adjustForAlignment(); // uses annotation's own record of
// sequence-column mapping
datasetSequence.addAlignmentAnnotation(_aa);
+
+ // transfer contact matrices
+ ContactMatrixI cm = getContactMatrixFor(aa);
+ if (cm != null)
+ {
+ datasetSequence.addContactListFor(_aa, cm);
+ }
}
}
}
////
//// Contact Matrix Holder Boilerplate
////
- ContactMapHolder cmholder = new ContactMapHolder();
+ ContactMapHolderI cmholder = new ContactMapHolder();
@Override
public Collection<ContactMatrixI> getContactMaps()
}
@Override
+ public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+ {
+ return cmholder.getContactMatrixFor(ann);
+ }
+
+ @Override
public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
{
return cmholder.getContactListFor(_aa, column);
;
}
aa.annotations = _aa;
+ aa.setSequenceRef(this);
+ aa.createSequenceMapping(this, getStart(), false);
addAlignmentAnnotation(aa);
return aa;
}
+ @Override
+ public void addContactListFor(AlignmentAnnotation annotation,
+ ContactMatrixI cm)
+ {
+ cmholder.addContactListFor(annotation, cm);
+ }
}
}
@Override
+ public ContactMatrixI getContactMatrixFor(AlignmentAnnotation ann)
+ {
+ return cmholder.getContactMatrixFor(ann);
+ }
+
+ @Override
public ContactListI getContactListFor(AlignmentAnnotation _aa, int column)
{
return cmholder.getContactListFor(_aa, column);
// TODO passing annotations back to context to be added
return aa;
}
+
+ @Override
+ public void addContactListFor(AlignmentAnnotation annotation,
+ ContactMatrixI cm)
+ {
+ cmholder.addContactListFor(annotation, cm);
+ }
+
}
*/
public int firstResidueOutsideIterator(Iterator<int[]> it);
+ public void addContactListFor(AlignmentAnnotation annotation,
+ ContactMatrixI cm);
+
}
Console.info("retrieving pAE for " + pdbId);
Alignment al = new Alignment(prot.toArray(new SequenceI[0]));
EBIAlfaFold.retrieve_AlphaFold_pAE(pdbId, al, null);
+ if (al.getAlignmentAnnotation() != null)
+ {
+ for (AlignmentAnnotation alann : al.getAlignmentAnnotation())
+ {
+ annotations.add(alann);
+ }
+ }
;
} catch (Throwable t)
{
"exception.no_pdb_records_for_chain", new String[]
{ id, ((chain == null) ? "' '" : chain) }));
}
- retrieve_AlphaFold_pAE(id, pdbAlignment, retrievalUrl);
+ // done during structure retrieval
+ // retrieve_AlphaFold_pAE(id, pdbAlignment, retrievalUrl);
} catch (Exception ex) // Problem parsing PDB file
{
pdbAlignment.getSequenceAt(0),
(Map<String, Object>) pae_obj.get(0));
- // THIS IS NOT GOING TO WORK !!!
- // ?? StructureFile assumes sequenceI holds all data, so AlignmentAnnotation
- // needs to hold the contact matrix data.
- pdbAlignment.getSequenceAt(0)
- .addAlignmentAnnotation(pdbAlignment.addContactList(matrix));
+ AlignmentAnnotation cmannot = pdbAlignment.getSequenceAt(0)
+ .addContactList(matrix);
+ pdbAlignment.addAnnotation(cmannot);
return true;
}
import jalview.analysis.AlignSeq;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
+import jalview.datamodel.ContactMatrixI;
import jalview.datamodel.Mapping;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
ana.getCalcId(), ana.label, ana.description);
if (transfer == null || transfer.size() == 0)
{
+ ContactMatrixI cm = shadow.getContactMatrixFor(ana);
ana = new AlignmentAnnotation(ana);
+ // TODO map contact matrix under mapping
ana.liftOver(sequence, shadowMap);
ana.liftOver(dsq, sqmpping);
dsq.addAlignmentAnnotation(ana);
+ if (cm != null)
+ {
+ dsq.addContactListFor(ana, cm);
+ }
}
else
{
ana.description);
if (transfer == null || transfer.size() == 0)
{
+ ContactMatrixI cm = sequence.getContactMatrixFor(ana);
ana = new AlignmentAnnotation(ana);
ana.liftOver(dsq, sqmpping);
dsq.addAlignmentAnnotation(ana);
- // mapping.transfer(ana);
+ if (cm != null)
+ {
+ dsq.addContactListFor(ana, cm);
+ }
}
else
{
dnaToPeptide);
assertSame(seq, cds1.getDatasetSequence());
}
+
+ @Test(groups = "Functional")
+ public void testAddReferenceContactMap()
+ {
+ SequenceI sq = new Sequence("a", "SSSQ");
+ ContactMatrixI cm = new SeqDistanceContactMatrix(4);
+ AlignmentAnnotation cm_aan = sq.addContactList(cm);
+ SequenceI dssq = sq.createDatasetSequence();
+ Alignment ds = new Alignment(new SequenceI[] { dssq });
+
+ // remove annotation on our non-dataset sequence
+ sq.removeAlignmentAnnotation(sq.getAnnotation()[0]);
+ // test transfer
+ Alignment al = new Alignment(new SequenceI[] { sq });
+ SortedMap<String, String> tipEntries = new TreeMap<>();
+ final Map<SequenceI, List<AlignmentAnnotation>> candidates = new LinkedHashMap<>();
+
+ AlignmentUtils.findAddableReferenceAnnotations(al.getSequences(),
+ tipEntries, candidates, al);
+ AlignmentUtils.addReferenceAnnotations(candidates, al, null);
+ assertTrue("No contact map annotation transferred",
+ al.getAlignmentAnnotation() != null
+ && al.getAlignmentAnnotation().length == 1);
+ AlignmentAnnotation alan = al.findAnnotations(sq, null, cm_aan.label)
+ .iterator().next();
+ ContactListI cl = al.getContactListFor(alan, 1);
+ assertNotNull(
+ "No contact matrix recovered after reference annotation transfer",
+ cl);
+
+ }
}
*/
package jalview.ws.seqfetcher;
-import static org.testng.Assert.assertNotEquals;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Assert;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
import jalview.analysis.CrossRef;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.ws.dbsources.Pdb;
import jalview.ws.dbsources.Uniprot;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
/**
* @author jimp
*
public void testAlphaFoldClien() throws Exception
{
DbSourceProxy alphafold = new EBIAlfaFold();
- AlignmentI resp = alphafold.getSequenceRecords(alphafold.getTestQuery());
+ AlignmentI resp = alphafold
+ .getSequenceRecords(alphafold.getTestQuery());
assertNotNull(resp);
- assertEquals("One sequence only",resp.getHeight(), 1);
- for (AlignmentAnnotation aa:resp.getAlignmentAnnotation()) {
+ assertEquals("One sequence only", resp.getHeight(), 1);
+ for (AlignmentAnnotation aa : resp.getAlignmentAnnotation())
+ {
if (aa.graph == AlignmentAnnotation.CUSTOMRENDERER)
{
- assertTrue("Contact map didn't provide valid contact",resp.getContactListFor(aa, 1).getContactAt(1)!=-1d);
+ assertTrue("Contact map didn't provide valid contact",
+ resp.getContactListFor(aa, 1).getContactAt(1) != -1d);
// test passes
return;
}
}
- Assert.fail();
+ Assert.fail("No pAE matrix found for alphafold structure.");
}
}