| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.gui; |
| 22 |
|
|
| 23 |
|
import java.io.File; |
| 24 |
|
|
| 25 |
|
import jalview.api.StructureSelectionManagerProvider; |
| 26 |
|
import jalview.bin.Console; |
| 27 |
|
import jalview.datamodel.PDBEntry; |
| 28 |
|
import jalview.datamodel.SequenceI; |
| 29 |
|
import jalview.io.DataSourceType; |
| 30 |
|
import jalview.io.StructureFile; |
| 31 |
|
import jalview.structure.StructureImportSettings.TFType; |
| 32 |
|
import jalview.structure.StructureSelectionManager; |
| 33 |
|
import jalview.util.MessageManager; |
| 34 |
|
import jalview.util.Platform; |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
@author |
| 41 |
|
|
| 42 |
|
|
| |
|
| 52.7% |
Uncovered Elements: 26 (55) |
Complexity: 18 |
Complexity Density: 0.58 |
|
| 43 |
|
public class AssociatePdbFileWithSeq |
| 44 |
|
{ |
| 45 |
|
|
| |
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 46 |
0 |
private AssociatePdbFileWithSeq()... |
| 47 |
|
{ |
| 48 |
|
|
| 49 |
|
} |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
@param |
| 56 |
|
|
| 57 |
|
@param |
| 58 |
|
|
| 59 |
|
@param |
| 60 |
|
|
| 61 |
|
@param |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
@return |
| 65 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 66 |
3 |
public static PDBEntry associatePdbWithSeq(String fileName,... |
| 67 |
|
DataSourceType type, SequenceI sequence, boolean prompt) |
| 68 |
|
{ |
| 69 |
3 |
return associatePdbWithSeq(fileName, type, sequence, null, prompt, Desktop.getInstance(), |
| 70 |
|
TFType.DEFAULT, null, false); |
| 71 |
|
} |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 72 |
67 |
public static PDBEntry associatePdbWithSeq(String fileName, DataSourceType type,... |
| 73 |
|
SequenceI sequence,boolean prompt, |
| 74 |
|
StructureSelectionManagerProvider ssmp, TFType tft, |
| 75 |
|
String paeFilename, boolean doXferSettings) |
| 76 |
|
{ |
| 77 |
67 |
return associatePdbWithSeq(fileName, type, sequence, null, prompt, ssmp, |
| 78 |
|
tft, paeFilename, doXferSettings); |
| 79 |
|
} |
| |
|
| 49% |
Uncovered Elements: 25 (49) |
Complexity: 15 |
Complexity Density: 0.52 |
|
| 80 |
72 |
public static PDBEntry associatePdbWithSeq(String fileName, DataSourceType type,... |
| 81 |
|
SequenceI sequence, String[] chains, boolean prompt, |
| 82 |
|
StructureSelectionManagerProvider ssmp, TFType tft, |
| 83 |
|
String paeFilename, boolean doXferSettings) |
| 84 |
|
{ |
| 85 |
72 |
PDBEntry entry = new PDBEntry(); |
| 86 |
|
|
| 87 |
72 |
SequenceI[] seqs= new SequenceI[chains==null ? 1 : chains.length]; |
| 88 |
144 |
for (int i=0;i<seqs.length;i++) { |
| 89 |
72 |
seqs[i] = sequence; |
| 90 |
|
} |
| 91 |
|
|
| 92 |
72 |
StructureFile pdbfile = StructureSelectionManager |
| 93 |
|
.getStructureSelectionManager(ssmp) |
| 94 |
|
.setMapping(false, seqs, chains, fileName, type, tft, paeFilename, |
| 95 |
|
doXferSettings); |
| 96 |
72 |
if (pdbfile == null) |
| 97 |
|
{ |
| 98 |
|
|
| 99 |
0 |
return null; |
| 100 |
|
} |
| 101 |
72 |
String id = pdbfile.getId(); |
| 102 |
? |
if (id == null && (id = (prompt |
| 103 |
|
? JvOptionPane.showInternalInputDialog(Desktop.getDesktopPane(), |
| 104 |
|
MessageManager |
| 105 |
|
.getString("label.couldnt_find_pdb_id_in_file"), |
| 106 |
|
MessageManager.getString("label.no_pdb_id_in_file"), |
| 107 |
|
JvOptionPane.QUESTION_MESSAGE) |
| 108 |
|
: null)) == null) |
| 109 |
|
{ |
| 110 |
0 |
return null; |
| 111 |
|
} |
| 112 |
|
|
| 113 |
|
|
| 114 |
72 |
File sfile=new File(fileName); |
| 115 |
72 |
if (sequence.getDatasetSequence()!=null && sequence.getDatasetSequence().hasPDBEntries()) { |
| 116 |
72 |
for (PDBEntry pe: sequence.getDatasetSequence().getAllPDBEntries()) { |
| 117 |
109 |
try { |
| 118 |
|
|
| 119 |
109 |
if (new File(pe.getFile()).getCanonicalPath().equals(sfile.getCanonicalPath())) { |
| 120 |
72 |
if (chains==null || chains[0].equals(pe.getChainCode())) { |
| 121 |
72 |
return pe; |
| 122 |
|
} |
| 123 |
|
} } catch (Exception ex) { |
| 124 |
0 |
Console.error("Unexpected exception when examining structure file paths",ex); |
| 125 |
|
} |
| 126 |
|
} |
| 127 |
|
} |
| 128 |
0 |
entry.setId(id); |
| 129 |
0 |
entry.setType(PDBEntry.Type.FILE); |
| 130 |
0 |
entry.setFile(fileName); |
| 131 |
0 |
sequence.getDatasetSequence().addPDBId(entry); |
| 132 |
0 |
entry.setStructureFile(pdbfile); |
| 133 |
0 |
StructureSelectionManager.getStructureSelectionManager(ssmp) |
| 134 |
|
.registerPDBEntry(entry); |
| 135 |
0 |
if (tft != null) |
| 136 |
0 |
entry.setTempFacType(tft); |
| 137 |
0 |
if (paeFilename != null) |
| 138 |
0 |
entry.setPAEFile(paeFilename); |
| 139 |
0 |
return entry; |
| 140 |
|
} |
| 141 |
|
} |