String maxChainId = " ";
PDBChain maxChain = null;
boolean first = true;
+ List<PDBChain> maximalChain = new ArrayList<>();
+ List<AlignSeq> maximalAlignseqs = new ArrayList<>();
+ List<String> maximalChainIds = new ArrayList<>();
for (PDBChain chain : pdb.getChains())
{
if (targetChainId.length() > 0 && !targetChainId.equals(chain.id)
// as.calcScoreMatrix();
// as.traceAlignment();
- if (first || as.maxscore > max
- || (as.maxscore == max && chain.id.equals(targetChainId)))
+ if (targetChainId.length() > 0 && chain.id.equals(targetChainId))
{
- first = false;
+ // Don't care - just pick this chain as the mapping
maxChain = chain;
max = as.maxscore;
maxAlignseq = as;
maxChainId = chain.id;
+ // if targetChainId is specified then it is expected to be unique, so
+ // precisely one maximal chain will be added
+ maximalChainIds.add(chain.id);
+ maximalChain.add(chain);
+ maximalAlignseqs.add(as);
+ }
+ else
+ {
+ // select chains with maximal mappings to this sequence
+ if (first || as.maxscore > max)
+ {
+ // clear out old maximal mappings (if any)
+ max = as.maxscore;
+ maximalChain.clear();
+ maxChain = chain;
+ max = as.maxscore;
+ maxAlignseq = as;
+ maxChainId = chain.id;
+ first = false;
+ }
+ if (as.maxscore == max)
+ {
+ maximalChainIds.add(chain.id);
+ maximalChain.add(chain);
+ maximalAlignseqs.add(as);
+ }
}
}
if (maxChain == null)
pdbFile = "INLINE" + pdb.getId();
}
- List<StructureMapping> seqToStrucMapping = new ArrayList<StructureMapping>();
+ List<StructureMapping> seqToStrucMapping = new ArrayList<>();
if (isMapUsingSIFTs && seq.isProtein())
{
setProgressBar(null);
// fall back to NW alignment
System.err.println(e.getMessage());
StructureMapping nwMapping = getNWMappings(seq, pdbFile,
- targetChainId, maxChain, pdb, maxAlignseq);
+ maximalChainIds, maximalChain, pdb, maximalAlignseqs)
+ .get(0);
seqToStrucMapping.add(nwMapping);
maxChain.makeExactMapping(maxAlignseq, seq);
maxChain.transferRESNUMFeatures(seq, null); // FIXME: is this
}
else
{
- List<StructureMapping> foundSiftsMappings = new ArrayList<StructureMapping>();
+ List<StructureMapping> foundSiftsMappings = new ArrayList<>();
for (PDBChain chain : pdb.getChains())
{
try
else
{
StructureMapping nwMapping = getNWMappings(seq, pdbFile,
- maxChainId, maxChain, pdb, maxAlignseq);
+ maximalChainIds, maximalChain, pdb, maximalAlignseqs)
+ .get(0);
seqToStrucMapping.add(nwMapping);
maxChain.transferRESNUMFeatures(seq, null); // FIXME: is this
// "IEA:Jalview" ?
setProgressBar(null);
setProgressBar(MessageManager
.getString("status.obtaining_mapping_with_nw_alignment"));
- StructureMapping nwMapping = getNWMappings(seq, pdbFile, maxChainId,
- maxChain, pdb, maxAlignseq);
- seqToStrucMapping.add(nwMapping);
- ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0));
+ List<StructureMapping> nwMapping = getNWMappings(seq, pdbFile,
+ maximalChainIds, maximalChain, pdb, maximalAlignseqs);
+ seqToStrucMapping.addAll(nwMapping);
+ for (PDBChain mc : maximalChain)
+ {
+ ds.addPDBId(mc.sequence.getAllPDBEntries().get(0));
+ }
+ ;
}
return curChainMapping;
}
- private StructureMapping getNWMappings(SequenceI seq, String pdbFile,
- String maxChainId, PDBChain maxChain, StructureFile pdb,
- AlignSeq maxAlignseq)
+ private List<StructureMapping> getNWMappings(SequenceI seq,
+ String pdbFile,
+ List<String> maximalChainId, List<PDBChain> maximalChain,
+ StructureFile pdb, List<AlignSeq> maximalAlignseq)
{
+ List<StructureMapping> nwMappings = new ArrayList();
+ for (int ch = 0; ch < maximalChain.size(); ch++)
+ {
+ String maxChainId = maximalChainId.get(ch);
+ PDBChain maxChain = maximalChain.get(ch);
+ AlignSeq maxAlignseq = maximalAlignseq.get(ch);
final StringBuilder mappingDetails = new StringBuilder(128);
mappingDetails.append(NEWLINE)
.append("Sequence \u27f7 Structure mapping details");
StructureMapping nwMapping = new StructureMapping(seq, pdbFile,
pdb.getId(), maxChainId, mapping, mappingDetails.toString());
maxChain.transferResidueAnnotation(nwMapping, sqmpping);
- return nwMapping;
+ nwMappings.add(nwMapping);
+ }
+ return nwMappings;
}
public void removeStructureViewerListener(Object svl, String[] pdbfiles)