else
{
alignmentToExport = viewport.getAlignment();
- alignmentStartEnd = viewport.getAlignment()
- .getVisibleStartAndEndIndex(
- viewport.getColumnSelection().getHiddenColumns());
}
+ alignmentStartEnd = alignmentToExport
+ .getVisibleStartAndEndIndex(viewport.getColumnSelection()
+ .getHiddenColumns());
AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
omitHidden, alignmentStartEnd, settings);
return ed;
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)
}
/**
- * Remove the following special characters from input string +, -, &, |, !, (,
- * ), {, }, [, ], ^, ", ~, *, ?, :, \
+ * Remove the following special characters from input string +, -, &, !, (, ),
+ * {, }, [, ], ^, ", ~, *, ?, :, \
*
* @param seqName
* @return
{
Objects.requireNonNull(seqName);
return seqName.replaceAll("\\[\\d*\\]", "")
- .replaceAll("[^\\dA-Za-z|]", "").replaceAll("\\s+", "+");
+ .replaceAll("[^\\dA-Za-z|_]", "").replaceAll("\\s+", "+");
}
FTSRestRequest pdbRequest = new FTSRestRequest();
if (fieldToFilterBy.equalsIgnoreCase("uniprot_coverage"))
{
- System.out.println(">>>>>> Filtering with uniprot coverate");
pdbRequest.setAllowEmptySeq(false);
pdbRequest.setResponseSize(1);
pdbRequest.setFieldToSearchBy("(");
{
int pdbIdColIndex = tbl_summary.getColumn("PDB Id")
.getModelIndex();
- int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
+ int refSeqColIndex = tbl_summary.getColumn("Ref Sequence")
.getModelIndex();
- int[] selectedRows = tbl_summary.getSelectedRows();
+ int[] selectedRows = tbl_summary.getSelectedRows();
PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
int count = 0;
ArrayList<SequenceI> selectedSeqsToView = new ArrayList<SequenceI>();
for (int row : selectedRows)
{
- String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
+ String pdbIdStr = tbl_summary.getValueAt(row, pdbIdColIndex)
.toString();
- SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
+ SequenceI selectedSeq = (SequenceI) tbl_summary.getValueAt(row,
refSeqColIndex);
selectedSeqsToView.add(selectedSeq);
PDBEntry pdbEntry = selectedSeq.getPDBEntry(pdbIdStr);
if (SiftsSettings.isMapWithSifts())
{
+ ArrayList<SequenceI> seqsWithoutSourceDBRef = new ArrayList<SequenceI>();
for (SequenceI seq : sequences)
{
- if (seq.getSourceDBRef() == null)
+ if (seq.getSourceDBRef() == null && seq.getDBRefs() == null)
{
- ssm.setProgressBar(null);
- ssm.setProgressBar("Fetching Database refs..");
- new DBRefFetcher(sequences).fetchDBRefs(true);
- break;
+ seqsWithoutSourceDBRef.add(seq);
+ continue;
+ }
+ }
+ if (!seqsWithoutSourceDBRef.isEmpty())
+ {
+ int y = seqsWithoutSourceDBRef.size();
+ ssm.setProgressBar(null);
+ ssm.setProgressBar("Fetching db refs for " + y
+ + " sequence" + (y > 1 ? "s" : "")
+ + " without valid db ref required for SIFTS mapping");
+ SequenceI[] seqWithoutSrcDBRef = new SequenceI[y];
+ int x = 0;
+ for (SequenceI fSeq : seqsWithoutSourceDBRef)
+ {
+ seqWithoutSrcDBRef[x++] = fSeq;
}
+ new DBRefFetcher(seqWithoutSrcDBRef).fetchDBRefs(true);
}
}
if (pdbEntriesToView.length > 1)
.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,
for (String file : files)
{
notLoaded = file;
+ if (file == null)
+ {
+ continue;
+ }
try
{
StructureMapping[] sm = getSsm().getMapping(file);
/*
* try to parse m..n (or simply m)
- * also handles <m..n or m..>n (discarding < or >)
*/
String[] range = location.split("\\.\\.");
if (range.length == 1 || range.length == 2)
{
try
{
- int start = parseRangeEnd(range[0]);
- int end = range.length == 1 ? start : parseRangeEnd(range[1]);
+ int start = Integer.valueOf(range[0]);
+ int end = range.length == 1 ? start : Integer.valueOf(range[1]);
return Collections.singletonList(new int[] { start, end });
} catch (NumberFormatException e)
{
}
/**
- * Returns the integer value of a locus, discarding any < or > prefix
- *
- * @throws NumberFormatException
- * if value is not numeric
- */
- static int parseRangeEnd(String loc)
- {
-
- if (loc.startsWith("<") || loc.startsWith(">"))
- {
- loc = loc.substring(1);
- }
- return Integer.valueOf(loc);
- }
-
- /**
* Parses a complement(locationSpec) into a list of start-end ranges
*
* @param location
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());
}
/**