X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=0f82650c2226e3a7acf0e9313fc5a59fbdcf7c8c;hb=4bc5c1c97bd08007b2ac9ccfd9b3cb29eac10193;hp=ad5da6700d4df7e3ab9e355200cc758eb8560aa4;hpb=832101caf0bd7b01d0103879875a724078ea118f;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index ad5da67..0f82650 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -26,10 +26,12 @@ import java.util.Arrays; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.IdentityHashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.Vector; import jalview.analysis.AlignSeq; @@ -522,32 +524,15 @@ public class StructureSelectionManager { ds = ds.getDatasetSequence(); } - + List putativePDBe = PDBEntryUtils.selectPutativePDBe(seq,ds, pdb); + if (targetChainIds != null && targetChainIds[s] != null) { infChain = false; targetChainId = targetChainIds[s]; } - else if (seq.getName().indexOf("|") > -1) - { - targetChainId = seq.getName() - .substring(seq.getName().lastIndexOf("|") + 1); - if (targetChainId.length() > 1) - { - if (targetChainId.trim().length() == 0) - { - targetChainId = " "; - } - else - { - // not a valid chain identifier - targetChainId = ""; - } - } - } - else - { - targetChainId = ""; + else { + targetChainId = PDBEntryUtils.inferChainId(seq); } /* @@ -567,13 +552,19 @@ public class StructureSelectionManager { continue; // don't try to map chains don't match. } + PDBEntry putativeChain = null; + if (!putativePDBe.isEmpty() && (putativeChain = PDBEntryUtils + .selectPutativePDBEntry(putativePDBe, chain)) == null) + { + continue; + } // TODO: correctly determine sequence type for mixed na/peptide // structures final String type = chain.isNa ? AlignSeq.DNA : AlignSeq.PEP; AlignSeq as = AlignSeq.doGlobalNWAlignment(seq, chain.sequence, type); // TODO: JAL-4366 determinine of a crummy alignment but exact match should make this chain the one to be mapped to a 3di sequence - if (as.s1str.length() == 4 + as.s2str.length()) + if (as.s1str.length() == as.s2str.length()) { idLengthChain = chain; } @@ -598,6 +589,7 @@ public class StructureSelectionManager } List seqToStrucMapping = new ArrayList<>(); + List foundSiftsMappings = new ArrayList<>(); if (isMapUsingSIFTs && seq.isProtein()) { if (progress != null) @@ -622,26 +614,15 @@ public class StructureSelectionManager pdb.getId().toLowerCase(Locale.ROOT)); maxChain.transferResidueAnnotation(siftsMapping, null); ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); + foundSiftsMappings.add(siftsMapping); } catch (SiftsException e) { - // fall back to NW alignment Console.error(e.getMessage()); - StructureMapping nwMapping = getNWMappings(seq, pdbFile, - targetChainId, maxChain, pdb, maxAlignseq); - seqToStrucMapping.add(nwMapping); - maxChain.makeExactMapping(maxAlignseq, seq); - maxChain.transferRESNUMFeatures(seq, "IEA:Jalview", - pdb.getId().toLowerCase(Locale.ROOT)); // FIXME: is - // this - // "IEA:Jalview" ? - maxChain.transferResidueAnnotation(nwMapping, sqmpping); - ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); } } else { - List foundSiftsMappings = new ArrayList<>(); for (PDBChain chain : pdb.getChains()) { StructureMapping siftsMapping = null; @@ -665,32 +646,25 @@ public class StructureSelectionManager jalview.bin.Console.errPrintln(e.getMessage()); } } + // If sifts was successful, add mappings and return if (!foundSiftsMappings.isEmpty()) { - seqToStrucMapping.addAll(foundSiftsMappings); ds.addPDBId(sqmpping.getTo().getAllPDBEntries().get(0)); } - else - { - /* - * fallback to NeedlemanWunch. - */ - StructureMapping nwMapping = getNWMappings(seq, pdbFile, - maxChainId, maxChain, pdb, maxAlignseq); - seqToStrucMapping.add(nwMapping); - maxChain.transferRESNUMFeatures(seq, null, - pdb.getId().toLowerCase(Locale.ROOT)); // FIXME: is this - // "IEA:Jalview" ? - maxChain.transferResidueAnnotation(nwMapping, sqmpping); - ds.addPDBId(maxChain.sequence.getAllPDBEntries().get(0)); - } + } + + // If sifts was successful, add mappings and return + if (!foundSiftsMappings.isEmpty()) + { + seqToStrucMapping.addAll(foundSiftsMappings); } } - else + if (foundSiftsMappings.isEmpty()) { - // Not doing SIFTS + // Not doing SIFTS, or SIFTS failed for some reason. + // first check if we should use an identity mapping - if (idLengthChain != null && maxAlignseq.getS2Coverage() < 0.5) + if (idLengthChain != null && maxAlignseq.getS2Coverage() < 0.75) { Console.info( "Assuming 3Dsi identity mapping between structure and sequence"); @@ -702,6 +676,11 @@ public class StructureSelectionManager } else { + if (maxAlignseq.getS1Coverage()<0.15 && maxAlignseq.getS2Coverage()<0.15) + { + // skip this - the NW alignment is spurious + continue; + } // Construct a needleman wunsch mapping instead. if (progress != null) {