1 |
duarte |
253 |
import java.sql.ResultSet; |
2 |
|
|
import java.sql.SQLException; |
3 |
|
|
import java.sql.Statement; |
4 |
|
|
|
5 |
|
|
import proteinstructure.Pdb; |
6 |
|
|
import proteinstructure.PdbChainCodeNotFoundError; |
7 |
|
|
import proteinstructure.PdbCodeNotFoundError; |
8 |
|
|
import proteinstructure.PdbaseInconsistencyError; |
9 |
|
|
import proteinstructure.PdbasePdb; |
10 |
|
|
import tools.MySQLConnection; |
11 |
|
|
|
12 |
|
|
|
13 |
|
|
public class benchmarkGraphAlgorithm { |
14 |
|
|
/*------------------------------ constants ------------------------------*/ |
15 |
|
|
|
16 |
|
|
// database with a list of pdb codes and chain codes to process |
17 |
|
|
public static String DB_NAME = "pdb_reps"; |
18 |
|
|
public static String DB_TABLE = "reps"; |
19 |
|
|
public static String DB_COL_PDB = "accession_code"; |
20 |
|
|
public static String DB_COL_CHAIN = "chain_pdb_code"; |
21 |
|
|
|
22 |
|
|
public static String PDB_DB = "pdbase_test"; |
23 |
|
|
public static String DB_HOST = "white"; |
24 |
|
|
public static String DB_USER = getUserName(); |
25 |
|
|
public static String DB_PWD = "nieve"; |
26 |
|
|
|
27 |
|
|
public static String PDB_CODE = "1tdr"; |
28 |
|
|
public static String CHAIN_CODE = "B"; |
29 |
|
|
public static double cutoff = 4.2; |
30 |
|
|
public static String edgeType = "ALL"; |
31 |
|
|
|
32 |
|
|
/*---------------------------- private methods --------------------------*/ |
33 |
|
|
/** |
34 |
|
|
* Get user name from operating system (for use as database username). |
35 |
|
|
* */ |
36 |
|
|
private static String getUserName() { |
37 |
|
|
String user = null; |
38 |
|
|
user = System.getProperty("user.name"); |
39 |
|
|
if(user == null) { |
40 |
|
|
System.err.println("Could not get user name from operating system."); |
41 |
|
|
} |
42 |
|
|
return user; |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
public static void main(String[] args) { |
46 |
|
|
MySQLConnection conn = null; |
47 |
|
|
String pdbCode, chainCode; |
48 |
|
|
int numPdbs = 0; |
49 |
|
|
|
50 |
|
|
// read command line parameters |
51 |
|
|
|
52 |
|
|
// read structures from database |
53 |
|
|
try{ |
54 |
|
|
conn = new MySQLConnection(DB_HOST, DB_USER, DB_PWD); |
55 |
|
|
} catch (Exception e) { |
56 |
|
|
System.err.println("Error opening database connection"); |
57 |
|
|
} |
58 |
|
|
String query = "SELECT DISTINCT " + DB_COL_PDB + "," + DB_COL_CHAIN + " FROM " + DB_NAME + "." + DB_TABLE + " LIMIT 1000;" ; |
59 |
|
|
Statement stmt; |
60 |
|
|
try { |
61 |
|
|
stmt = conn.createStatement(); |
62 |
|
|
ResultSet rs = stmt.executeQuery(query); |
63 |
|
|
while(rs.next()) { |
64 |
|
|
pdbCode = rs.getString(1); |
65 |
|
|
chainCode = rs.getString(2); |
66 |
|
|
|
67 |
|
|
if(chainCode == null) { |
68 |
|
|
chainCode = "NULL"; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
numPdbs++; |
72 |
|
|
// get graphs |
73 |
|
|
|
74 |
|
|
Pdb pdb = null; |
75 |
|
|
try { |
76 |
|
|
pdb = new PdbasePdb(pdbCode, chainCode, PDB_DB, conn); |
77 |
|
|
int length = pdb.get_length(); |
78 |
|
|
int atoms = pdb.getNumAtoms(); |
79 |
|
|
if (atoms>3000) { |
80 |
|
|
// get graph |
81 |
|
|
long start = System.currentTimeMillis(); |
82 |
|
|
pdb.get_graph(edgeType, cutoff); |
83 |
|
|
long end = System.currentTimeMillis(); |
84 |
|
|
|
85 |
|
|
System.out.print(pdbCode+"_"+chainCode); |
86 |
|
|
System.out.print("\t"+length+"\t"+atoms); |
87 |
|
|
System.out.printf("\t%4.3f",(double) (end-start)/1000); |
88 |
|
|
System.out.println(); |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
} catch (PdbaseInconsistencyError e) { |
92 |
|
|
System.out.println("Inconsistency in " + pdbCode + chainCode); |
93 |
|
|
} catch (PdbCodeNotFoundError e) { |
94 |
|
|
e.printStackTrace(); |
95 |
|
|
} catch (SQLException e) { |
96 |
|
|
e.printStackTrace(); |
97 |
|
|
} catch (PdbChainCodeNotFoundError e) { |
98 |
|
|
e.printStackTrace(); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
} |
106 |
|
|
System.out.println(); |
107 |
|
|
|
108 |
|
|
} catch (SQLException e) { |
109 |
|
|
e.printStackTrace(); |
110 |
|
|
} |
111 |
|
|
|
112 |
|
|
// output results |
113 |
|
|
System.out.println("Number of structures: " + numPdbs); |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
} |