List<SequenceI[]> seqvectors = new ArrayList<SequenceI[]>();
for (PDBEntry pdb : pdbEntries)
{
- List<SequenceI> seqs = new ArrayList<SequenceI>();
+ List<SequenceI> choosenSeqs = new ArrayList<SequenceI>();
for (SequenceI sq : alignment.getSequences())
{
- Vector<PDBEntry> pdbs = sq.getDatasetSequence().getAllPDBEntries();
- if (pdbs == null)
+ Vector<PDBEntry> pdbRefEntries = sq.getDatasetSequence().getAllPDBEntries();
+ if (pdbRefEntries == null)
{
continue;
}
- for (PDBEntry p1 : pdbs)
+ for (PDBEntry pdbRefEntry : pdbRefEntries)
{
- if (p1.getId().equals(pdb.getId()))
+ if (pdbRefEntry.getId().equals(pdb.getId()))
{
- if (!seqs.contains(sq))
+ if (pdbRefEntry.getChainCode() != null
+ && pdb.getChainCode() != null)
{
- seqs.add(sq);
- continue;
+ if (pdbRefEntry.getChainCode().equalsIgnoreCase(
+ pdb.getChainCode())
+ && !choosenSeqs.contains(sq))
+ {
+ choosenSeqs.add(sq);
+ continue;
+ }
}
+ else
+ {
+ if (!choosenSeqs.contains(sq))
+ {
+ choosenSeqs.add(sq);
+ continue;
+ }
+ }
+
}
}
}
- seqvectors.add(seqs.toArray(new SequenceI[seqs.size()]));
+ seqvectors.add(choosenSeqs.toArray(new SequenceI[choosenSeqs.size()]));
}
return seqvectors.toArray(new SequenceI[seqvectors.size()][]);
}
*
* @param featureSettings
*/
+ @Override
public void applyFeaturesStyle(FeatureSettingsModelI featureSettings)
{
if (featureSettings == null)
FTSRestRequest pdbRequest = new FTSRestRequest();
if (fieldToFilterBy.equalsIgnoreCase("uniprot_coverage"))
{
- System.out.println(">>>>>> Filtering with uniprot coverate");
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(1);
pdbRequest.setFieldToSearchBy("(");
ArrayList<SequenceI> seqsWithoutSourceDBRef = new ArrayList<SequenceI>();
for (SequenceI seq : sequences)
{
- if (seq.getSourceDBRef() == null)
+ if (seq.getSourceDBRef() == null && seq.getDBRefs() == null)
{
- if (seq.getDBRefs() == null)
- {
seqsWithoutSourceDBRef.add(seq);
continue;
}
- for (DBRefEntry dbRef : seq.getDBRefs())
- {
- if (dbRef.getSource().equalsIgnoreCase("uniprot"))
- {
- seq.setSourceDBRef(dbRef);
- break;
- }
- }
- for (DBRefEntry dbRef : seq.getDBRefs())
- {
- if (dbRef.getSource().equalsIgnoreCase("pdb"))
- {
- seq.setSourceDBRef(dbRef);
- break;
- }
- }
- if (seq.getSourceDBRef() == null)
- {
- seqsWithoutSourceDBRef.add(seq);
- }
- }
}
if (!seqsWithoutSourceDBRef.isEmpty())
{
int y = seqsWithoutSourceDBRef.size();
ssm.setProgressBar(null);
- ssm.setProgressBar(">>>>> Fetching Database refs for " + y
- + " sequence" + (y > 1 ? "s" : "")
- + " with no valid uniprot or pdb ref for SIFTS mapping");
- System.out.println(">>>>> Fetching Database refs for " + y
+ ssm.setProgressBar("Fetching db refs for " + y
+ " sequence" + (y > 1 ? "s" : "")
- + " with no valid uniprot or pdb ref for SIFTS mapping");
+ + " without valid db ref required for SIFTS mapping");
SequenceI[] seqWithoutSrcDBRef = new SequenceI[y];
int x = 0;
for (SequenceI fSeq : seqsWithoutSourceDBRef)
.getMappingFromS1(false);
if (targetChainId != null && !targetChainId.trim().isEmpty())
{
- StructureMapping mapping = getStructureMapping(seq, pdbFile,
- targetChainId, pdb, maxChain, sqmpping, maxAlignseq);
- seqToStrucMapping.add(mapping);
+ StructureMapping mapping;
+ try
+ {
+ mapping = getStructureMapping(seq, pdbFile, targetChainId, pdb,
+ maxChain, sqmpping, maxAlignseq);
+ seqToStrucMapping.add(mapping);
+ } catch (SiftsException e)
+ {
+ // e.printStackTrace();
+ // fall back to NW alignment
+ System.err.println(e.getMessage());
+ seqToStrucMapping.add(getNWMappings(seq, pdbFile,
+ targetChainId,
+ maxChain, pdb, maxAlignseq));
+ }
}
else
{
- for (PDBChain chain : pdb.getChains())
+ try
{
- StructureMapping mapping = getStructureMapping(seq, pdbFile,
- chain.id, pdb, chain, sqmpping, maxAlignseq);
- seqToStrucMapping.add(mapping);
+ ArrayList<StructureMapping> tempMapping = new ArrayList<StructureMapping>();
+ for (PDBChain chain : pdb.getChains())
+ {
+ StructureMapping mapping = getStructureMapping(seq, pdbFile,
+ chain.id, pdb, chain, sqmpping, maxAlignseq);
+ tempMapping.add(mapping);
+ }
+ seqToStrucMapping.addAll(tempMapping);
+ } catch (SiftsException e)
+ {
+ // e.printStackTrace();
+ // fall back to NW alignment
+ System.err.println(e.getMessage());
+ seqToStrucMapping.add(getNWMappings(seq, pdbFile, maxChainId,
+ maxChain, pdb, maxAlignseq));
}
}
}
private StructureMapping getStructureMapping(SequenceI seq,
String pdbFile, String targetChainId, StructureFile pdb,
PDBChain maxChain, jalview.datamodel.Mapping sqmpping,
- AlignSeq maxAlignseq)
+ AlignSeq maxAlignseq) throws SiftsException
{
- String maxChainId = targetChainId;
- try
- {
StructureMapping curChainMapping = siftsClient
.getSiftsStructureMapping(seq, pdbFile, targetChainId);
try
e.printStackTrace();
}
return curChainMapping;
- } catch (SiftsException e)
- {
- System.err.println(e.getMessage());
- System.err.println(">>> Now switching mapping with NW alignment...");
- setProgressBar(null);
- setProgressBar(">>> Now switching mapping with NW alignment...");
- return getNWMappings(seq, pdbFile, maxChainId, maxChain, pdb,
- maxAlignseq);
- }
}
private StructureMapping getNWMappings(SequenceI seq,
DBRefEntry[] dbRefs = seq.getDBRefs();
if (dbRefs == null || dbRefs.length < 1)
{
- throw new SiftsException("Could not get source DB Ref");
+ throw new SiftsException(
+ "Source DBRef could not be determined. DBRefs might not have been retrieved.");
}
for (DBRefEntryI dbRef : dbRefs)
&& (dbRef.getSource().equalsIgnoreCase(DBRefSource.UNIPROT) || dbRef
.getSource().equalsIgnoreCase(DBRefSource.PDB)))
{
+ seq.setSourceDBRef(dbRef);
return dbRef;
}
}
.getMapRegion();
for (MapRegion mapRegion : mapRegions)
{
- accessions.add(mapRegion.getDb().getDbAccessionId());
+ accessions
+ .add(mapRegion.getDb().getDbAccessionId().toLowerCase());
}
}
}
jalview.util.Comparison.GapChars, seq.getSequenceAsString());
HashMap<Integer, int[]> mapping = new HashMap<Integer, int[]>();
DBRefEntryI sourceDBRef = seq.getSourceDBRef();
- if (sourceDBRef == null)
- {
- sourceDBRef = getValidSourceDBRef(seq);
- // TODO ensure sequence start/end is in the same coordinate system and
- // consistent with the choosen sourceDBRef
- }
+ sourceDBRef = getValidSourceDBRef(seq);
+ // TODO ensure sequence start/end is in the same coordinate system and
+ // consistent with the choosen sourceDBRef
// set sequence coordinate system - default value is UniProt
if (sourceDBRef.getSource().equalsIgnoreCase(DBRefSource.PDB))
private boolean isFoundInSiftsEntry(String accessionId)
{
+ HashSet<String> siftsDBRefs = getAllMappingAccession();
return accessionId != null
- && getAllMappingAccession().contains(accessionId);
+ && siftsDBRefs.contains(accessionId.toLowerCase());
}
/**