Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.gui

File AssociatePdbFileWithSeq.java

 

Coverage histogram

../../img/srcFileCovDistChart8.png
20% of files have more coverage

Code metrics

10
19
3
1
109
60
9
0.47
6.33
3
3

Classes

Class Line # Actions
AssociatePdbFileWithSeq 39 19 9
0.7575%
 

Contributing tests

This file is covered by 31 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.gui;
22   
23    import jalview.api.StructureSelectionManagerProvider;
24    import jalview.datamodel.PDBEntry;
25    import jalview.datamodel.SequenceI;
26    import jalview.io.DataSourceType;
27    import jalview.io.StructureFile;
28    import jalview.structure.StructureImportSettings.TFType;
29    import jalview.structure.StructureSelectionManager;
30    import jalview.util.MessageManager;
31   
32    /**
33    * GUI related routines for associating PDB files with sequences. A single
34    * static method.
35    *
36    * @author JimP
37    *
38    */
 
39    public class AssociatePdbFileWithSeq
40    {
41   
 
42  0 toggle private AssociatePdbFileWithSeq()
43    {
44    // inaccessible
45    }
46   
47    /**
48    * Associate the given PDB file name or URL with a sequence. Do not map
49    * mouse-over events.
50    *
51    * @param fileName
52    * or URL
53    * @param type
54    * will be DataType.FILE or DataType.URL
55    * @param sequence
56    * to associate
57    * @param prompt
58    * true if the user should be asked what to do if the specified file
59    * does not seem to contain PDB information (StructureChooser only)
60    * @return null if file is not found
61    */
 
62  3 toggle public static PDBEntry associatePdbWithSeq(String fileName,
63    DataSourceType type, SequenceI sequence, boolean prompt)
64    {
65  3 return associatePdbWithSeq(fileName, type, sequence, prompt, Desktop.getInstance(),
66    TFType.DEFAULT, null, false);
67    }
 
68  70 toggle public static PDBEntry associatePdbWithSeq(String fileName, DataSourceType type,
69    SequenceI sequence, boolean prompt,
70    StructureSelectionManagerProvider ssmp, TFType tft,
71    String paeFilename, boolean doXferSettings)
72    {
73  70 PDBEntry entry = new PDBEntry();
74   
75  70 StructureFile pdbfile = StructureSelectionManager
76    .getStructureSelectionManager(ssmp)
77    .setMapping(false, new SequenceI[]
78    { sequence }, null, fileName, type, tft, paeFilename,
79    doXferSettings);
80  70 if (pdbfile == null)
81    {
82    // stacktrace already thrown so just return
83  0 return null;
84    }
85  70 String id = pdbfile.getId();
86  ? if (id == null && (id = (prompt
87    ? JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(),
88    MessageManager
89    .getString("label.couldnt_find_pdb_id_in_file"),
90    MessageManager.getString("label.no_pdb_id_in_file"),
91    JvOptionPane.QUESTION_MESSAGE)
92    : null)) == null)
93    {
94  0 return null;
95    }
96  70 entry.setId(id);
97  70 entry.setType(PDBEntry.Type.FILE);
98  70 entry.setFile(fileName);
99  70 sequence.getDatasetSequence().addPDBId(entry);
100  70 entry.setStructureFile(pdbfile);
101  70 StructureSelectionManager.getStructureSelectionManager(ssmp)
102    .registerPDBEntry(entry);
103  70 if (tft != null)
104  54 entry.setTempFacType(tft);
105  70 if (paeFilename != null)
106  32 entry.setPAEFile(paeFilename);
107  70 return entry;
108    }
109    }