From f4c55ce8e067fc6ae84a6ae614cebed6c88a81f0 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Mon, 6 Jun 2016 14:49:31 +0100 Subject: [PATCH] JAL-1919, JAL-1960 fix to disable refetching dbrefs when viewing structures --- src/jalview/gui/StructureChooser.java | 62 +++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 46731e9..6471795 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -331,8 +331,8 @@ public class StructureChooser extends GStructureChooser implements } /** - * Remove the following special characters from input string +, -, &, |, !, (, - * ), {, }, [, ], ^, ", ~, *, ?, :, \ + * Remove the following special characters from input string +, -, &, !, (, ), + * {, }, [, ], ^, ", ~, *, ?, :, \ * * @param seqName * @return @@ -341,7 +341,7 @@ public class StructureChooser extends GStructureChooser implements { Objects.requireNonNull(seqName); return seqName.replaceAll("\\[\\d*\\]", "") - .replaceAll("[^\\dA-Za-z|]", "").replaceAll("\\s+", "+"); + .replaceAll("[^\\dA-Za-z|_]", "").replaceAll("\\s+", "+"); } @@ -732,17 +732,17 @@ public class StructureChooser extends GStructureChooser implements { 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 selectedSeqsToView = new ArrayList(); 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); @@ -859,15 +859,55 @@ public class StructureChooser extends GStructureChooser implements if (SiftsSettings.isMapWithSifts()) { + ArrayList seqsWithoutSourceDBRef = new ArrayList(); for (SequenceI seq : sequences) { if (seq.getSourceDBRef() == null) { - ssm.setProgressBar(null); - ssm.setProgressBar("Fetching Database refs.."); - new DBRefFetcher(sequences).fetchDBRefs(true); - break; + 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 + + " sequence" + (y > 1 ? "s" : "") + + " with no valid uniprot or pdb ref 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) -- 1.7.10.2