Skip to content

Commit 84b2fb1

Browse files
committed
v5.7.0
Small enhancements
1 parent 10f6a1e commit 84b2fb1

22 files changed

Lines changed: 848 additions & 546 deletions

java/src/backend/AnchorMain.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,17 @@ private boolean addPseudoGrpGrp(int grpIdx, String where, String annoStr, int i,
331331
String type = Globals.pseudoType;
332332

333333
// Must count pseudo too so as to not repeat pseudo numbers
334-
int genes = dbc2.executeCount("select count(*) from pseudo_annot "
335-
+ "where (type='gene' or type='pseudo') and grp_idx="+ grpIdx);
334+
// CAS570 would still duplicate pseudo, which worked as in different pairs, but confusing
335+
//int genes = dbc2.executeCount("select count(*) from pseudo_annot where (type='gene' or type='pseudo') and grp_idx="+ grpIdx);
336+
337+
int genes = dbc2.executeCount("select max(genenum) from pseudo_annot where grp_idx="+ grpIdx);
336338
int geneStart = genes;
337339
if (genes==0) geneStart = 1;
338-
else if (genes<1000) geneStart = (int)((Math.floor((double) genes/100.0)+1) * 100.0);
339-
else if (genes<10000) geneStart = (int)((Math.floor((double) genes/1000.0)+1) * 1000.0);
340-
else if (genes<100000) geneStart = (int)((Math.floor((double) genes/10000.0)+1) * 10000.0);
340+
else {
341+
int rem = genes%100;
342+
int add = 100-rem;
343+
geneStart += add;
344+
}
341345
int genenum = geneStart;
342346

343347
// find pseudo

java/src/database/Schema.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ public Schema(Connection conn) {
194194
"cvgpct TINYINT UNSIGNED NOT NULL," + // avg %sim Col7
195195
"countpct INTEGER UNSIGNED default 0," + // number of merged
196196
"score INTEGER NOT NULL," + // summed length Col5 - displayed in Query
197-
"htype TINYTEXT," + // EE, EI, IE, En, nE, II, In, nI, nn
197+
"htype TINYTEXT," + // EE, EI, IE, En, nE, II, In, nI, nn; g2, g1, g0
198198
"gene_overlap TINYINT NOT NULL, " + // 0,1,2
199-
"annot1_idx INTEGER default 0," +
199+
"annot1_idx INTEGER default 0," + // can have>0 when pseudo_annot.type='pseudo'
200200
"annot2_idx INTEGER default 0," +
201201
"strand TEXT NOT NULL," +
202202
"start1 INTEGER NOT NULL," +

java/src/props/PropsDB.java

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,65 +10,72 @@
1010

1111
/******************************************************
1212
* Used by Explorer and one call in dotplot; it read proj_props, plus check for pairs
13-
* CAS552 move ProjectPair class to here; removed lots of unused stuff; renamed from ProjectPool
13+
* dbProp contains everything in the proj_props DB table
14+
* Vector of pairs, Array of projects CAS570 renamed some stuff
1415
*/
1516
public class PropsDB {
16-
private DatabaseProperties dbProp;
17-
private Vector <ProjectPair> projectPairs;
18-
private ProjectObj[] projects;
17+
private DatabaseProperties dbProjProp;
18+
private Vector <Pair> pairs;
19+
private Project[] projects;
1920
private DBconn2 dbc2;
2021

2122
public PropsDB(DBconn2 dbc2) { // DrawingPanel and Dotplot.Data
2223
this.dbc2 = dbc2;
23-
projectPairs = new Vector<ProjectPair>();
24-
dbProp = new DatabaseProperties();
24+
pairs = new Vector<Pair>();
25+
dbProjProp = new DatabaseProperties();
2526
load();
2627
}
2728

2829
private void load() {
2930
try {
30-
projectPairs.clear();
31-
dbProp.load(dbc2);
31+
pairs.clear();
32+
33+
// Projects
34+
dbProjProp.loadAllProps(dbc2);
3235

33-
Vector<ProjectObj> pvector = new Vector<ProjectObj>();
36+
Vector<Project> pvector = new Vector<Project>();
3437

3538
ResultSet rs = null;
3639
int id, p1id, p2id;
3740

3841
rs = dbc2.executeQuery("select idx,type,name from projects");
3942
while (rs.next()) {
4043
id = rs.getInt(1);
41-
pvector.add(new ProjectObj(id,rs.getString(3),rs.getString(2)));
44+
pvector.add(new Project(id,rs.getString(3),rs.getString(2)));
4245
}
4346
rs.close();
4447

4548
if (!pvector.isEmpty()) {
46-
projects = new ProjectObj[pvector.size()];
47-
projects = (ProjectObj[])pvector.toArray(projects);
49+
projects = new Project[pvector.size()];
50+
projects = (Project[])pvector.toArray(projects);
4851
}
49-
52+
// Pairs
5053
rs = dbc2.executeQuery("SELECT idx,proj1_idx,proj2_idx FROM pairs");
5154
while (rs.next()) {
5255
p1id = rs.getInt(2);
5356
p2id = rs.getInt(3);
54-
projectPairs.add( new ProjectPair(rs.getInt(1), p1id, p2id) );
57+
pairs.add( new Pair(rs.getInt(1), p1id, p2id) );
5558
}
5659

57-
for (ProjectPair pp : projectPairs) {// CAS552 add for Sequence popup
60+
for (Pair pp : pairs) {// for Sequence popup
5861
String x = dbc2.executeString("select value from pair_props where name='algo1' and pair_idx=" + pp.pid);
5962
pp.isAlgo1 = (x!=null) ? x.equals("1") : true;
63+
x = dbc2.executeString("select value from pair_props where name='number_pseudo' and pair_idx=" + pp.pid);
64+
pp.hasPseudo = (x!=null) ? x.equals("1") : false;
6065
}
6166
rs.close();
6267
}
6368
catch (Exception e) {ErrorReport.print(e, "Project pool reset");}
6469
}
65-
70+
6671
public boolean isAlgo1(int pp1, int pp2) {
67-
if (hasProjectPair(pp1, pp2)) return getProjectPair(pp1, pp2).isAlgo1;
68-
else return getProjectPair(pp2, pp1).isAlgo1;
72+
if (hasPair(pp1, pp2)) return getPair(pp1, pp2).isAlgo1;
73+
if (hasPair(pp2, pp1)) return getPair(pp2, pp1).isAlgo1;
74+
return false;
6975
}
76+
7077
public String getProperty(int projectID, String property) { // Sequence
71-
return dbProp.getProperty((Object) projectID,property);
78+
return dbProjProp.getProperty((Object) projectID,property);
7279
}
7380

7481
public String getName(int projectID) { // Sequence
@@ -82,49 +89,54 @@ public String getDisplayName(int projectID) { // Sequence
8289
return getProperty(projectID,"display_name");
8390
}
8491

85-
public boolean hasProjectPair(int p1, int p2) { // MapperPool
86-
for (ProjectPair pp : projectPairs) {
92+
public boolean hasPair(int p1, int p2) { // MapperPool
93+
for (Pair pp : pairs) {
8794
if (pp.p1 == p1 && pp.p2 == p2)
8895
return true;
8996
}
9097
return false;
9198
}
99+
public boolean hasPseudo(int pp1, int pp2) { // MapperPool
100+
if (hasPair(pp1, pp2)) return getPair(pp1, pp2).hasPseudo;
101+
if (hasPair(pp2, pp1)) return getPair(pp2, pp1).hasPseudo;
102+
return false;
103+
}
92104

93105
public boolean isSwapped(int pX, int pY) { // Data
94-
ProjectPair pair = getProjectPair(pX, pY);
106+
Pair pair = getPair(pX, pY);
95107
return (pair == null || pX == pair.getP1());
96108
}
97-
private ProjectPair getProjectPair(int p1, int p2) {
98-
for (ProjectPair pp : projectPairs) {
99-
if ((pp.getP1() == p1 && pp.getP2() == p2)
100-
|| (pp.getP1() == p2 && pp.getP2() == p1))
109+
private Pair getPair(int p1, int p2) {
110+
for (Pair pp : pairs) {
111+
if ((pp.getP1() == p1 && pp.getP2() == p2) || (pp.getP1() == p2 && pp.getP2() == p1))
101112
return pp;
102113
}
103114
return null;
104115
}
105116
/////////////////////////////////////////////////////////////////////
106-
protected class ProjectObj {
117+
protected class Project {
107118
protected int id;
108119
protected String name;
109120
protected String type;
110-
111-
protected ProjectObj(int id, String name, String type) {
121+
122+
protected Project(int id, String name, String type) {
112123
this.id = id;
113124
if (name == null) this.name = "";
114125
else this.name = name;
115126
this.type = type.intern();
116127
}
117128

118129
public boolean equals(Object obj) {
119-
return obj instanceof ProjectObj && ((ProjectObj)obj).id == id;
130+
return obj instanceof Project && ((Project)obj).id == id;
120131
}
121132
}
122-
private class ProjectPair {
133+
private class Pair {
123134
private int p1, p2;
124135
private int pid;
125136
private boolean isAlgo1=false;
137+
private boolean hasPseudo=false; // CAS570 add for MapperPool to know if need to set annot_hits annot_idx to 0
126138

127-
protected ProjectPair(int pid, int p1, int p2) {
139+
protected Pair(int pid, int p1, int p2) {
128140
this.pid = pid;
129141
this.p1 = p1;
130142
this.p2 = p2;
@@ -138,16 +150,14 @@ protected ProjectPair(int pid, int p1, int p2) {
138150

139151
/**
140152
* Class DatabaseProperties can load properties from a database for quick access.
141-
* @see Properties CAS534 moved from a separate file in util; this needs cleaning...
142153
*/
143154
@SuppressWarnings("serial") // Prevent compiler warning for missing serialVersionUID
144-
public class DatabaseProperties extends Properties {
155+
private class DatabaseProperties extends Properties {
145156
public static final String SEPARATOR = ":##:";
146157

147-
private DatabaseProperties() {
148-
super();
149-
}
150-
private void load(DBconn2 dbc2) throws Exception {
158+
private DatabaseProperties() {super();}
159+
160+
private void loadAllProps(DBconn2 dbc2) throws Exception {
151161
ResultSet rs = null;
152162
try {
153163
rs = dbc2.executeQuery("SELECT proj_idx, name, value from proj_props");
@@ -157,13 +167,11 @@ private void load(DBconn2 dbc2) throws Exception {
157167
}
158168
finally {
159169
if (rs != null) {
160-
try { rs.close();
161-
} catch (Exception e) { }
170+
try { rs.close();} catch (Exception e) { }
162171
rs = null;
163172
}
164173
}
165174
}
166-
167175
protected String getProperty(Object id, String name) {
168176
return getProperty(getKey(id,name));
169177
}

java/src/symap/Globals.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* See DBconn2 for checking database variables
1414
*/
1515
public class Globals {
16-
public static final String VERSION = "v5.6.9";
17-
public static final String DATE = " (19-June-25)";
16+
public static final String VERSION = "v5.7.0";
17+
public static final String DATE = " (20-July-25)";
1818
public static final String VERDATE = VERSION + " " + DATE;
1919
public static final int DBVER = 7; // CAS512 v3, CAS520 v4, CAS522 v5, CAS543 v6, CAS546 v7
2020
public static final String DBVERSTR = "db" + DBVER;
@@ -110,4 +110,5 @@ public static void rclear() {
110110
public static void tprt(int num, String msg) {if (TRACE) System.out.format("%,10d %s\n",num, msg);}
111111
public static void dprt(String msg) {if (DEBUG) System.out.println(msg);}
112112
public static void deprt(String msg) {if (DEBUG) System.err.println(msg);}
113+
public static String toTF(boolean b) {return (b) ? "T" : "F";}
113114
}

java/src/symap/closeup/TextShowInfo.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public TextShowInfo (Component parentFrame, String title, String theInfo, Annota
6969
setTitle(title);
7070
setResizable(true);
7171

72-
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // CAS543 add the explicit close
72+
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
7373
addWindowListener(new WindowAdapter() {
7474
public void windowClosed(WindowEvent e) {annoDataObj.setIsPopup(false);}
7575
});
@@ -94,12 +94,12 @@ public TextShowInfo (Component parentFrame, String title, String theInfo, Annota
9494

9595
Dimension d = new Dimension (330, 200);
9696
if (getWidth() >= d.width || getHeight() >= d.height) setSize(d);
97-
setAlwaysOnTop(true); // CAS543; doesn't work on Ubuntu
97+
setAlwaysOnTop(true); // doesn't work on Ubuntu
9898
setLocationRelativeTo(null);
9999
setVisible(true);
100100
}
101101
/***************************************************
102-
* 2D Hit info; CAS560 change parameters, add Sort and Merge
102+
* 2D Hit info;
103103
*/
104104
public TextShowInfo (AlignPool alignPool, HitData hitDataObj, String title, String theInfo, String trailer,
105105
boolean st1LTst2, String proj1, String proj2, Annotation aObj1, Annotation aObj2, String queryHits, String targetHits,
@@ -110,30 +110,33 @@ public TextShowInfo (AlignPool alignPool, HitData hitDataObj, String title, Stri
110110
setTitle(title);
111111
setResizable(true);
112112

113-
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // CAS543 add the explicit close
113+
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
114114
addWindowListener(new WindowAdapter() {
115115
public void windowClosed(WindowEvent e) {hitDataObj.setIsPopup(false);}
116116
});
117117

118118
this.alignPool = alignPool; this.hitDataObj = hitDataObj;
119119
this.title = title; this.theInfo = theInfo;
120120
this.proj1 = proj1; this.proj2 = proj2;
121-
this.aObj1 = aObj1; this.aObj2 = aObj2; // CAS560 change from name to object for coords
121+
this.aObj1 = aObj1; this.aObj2 = aObj2;
122122
this.queryHits = queryHits; this.targetHits = targetHits;
123123
this.isQuery = isQuery; this.st1LTst2 = st1LTst2; this.isInvHit = isInv;
124124

125-
String gene1 = (aObj1!=null) ? " (#" + aObj1.getFullGeneNum() + ")" : "";
126-
String gene2 = (aObj2!=null) ? " (#" + aObj2.getFullGeneNum() + ")" : "";
125+
String gene1 = (aObj1!=null) ? " #" + aObj1.getFullGeneNum() : "";
126+
String gene2 = (aObj2!=null) ? " #" + aObj2.getFullGeneNum() : "";
127127

128128
boolean bMerge = title.startsWith(titleMerge);
129129
boolean bOrder = title.startsWith(titleOrder);
130130
boolean bRemove = title.startsWith(titleRemove);
131131

132+
String name1 = String.format("%-16s %s", proj1, gene1);// CAS570 removed () and line up gene#
133+
String name2 = String.format("%-16s %s", proj2, gene2);
134+
132135
/** Text - the tables and info **/
133-
String table1 = SeqDataInfo.formatHit(Globals.Q, proj1 + gene1, aObj1, queryHits, title, false, false);
136+
String table1 = SeqDataInfo.formatHit(Globals.Q, name1, aObj1, queryHits, title, false, false);
134137
int cntNegGap = SeqDataInfo.cntMergeNeg;
135138

136-
String table2 = SeqDataInfo.formatHit(Globals.T, proj2 + gene2, aObj2, targetHits, title, isInv, bSort);
139+
String table2 = SeqDataInfo.formatHit(Globals.T, name2, aObj2, targetHits, title, isInv, bSort);
137140
cntNegGap += SeqDataInfo.cntMergeNeg;
138141

139142
// theInfo
@@ -190,7 +193,7 @@ public TextShowInfo (AlignPool alignPool, HitData hitDataObj, String title, Stri
190193

191194
Dimension d = new Dimension (350, 200); // w,h
192195
if (getWidth() >= d.width || getHeight() >= d.height) setSize(d);
193-
setAlwaysOnTop(true); // CAS543; doesn't work on Ubuntu
196+
setAlwaysOnTop(true);
194197
setLocationRelativeTo(null);
195198
setVisible(true);
196199
}
@@ -221,7 +224,7 @@ private void addAlign(Vector <String> lines, String aSeq1, String aSeqM, String
221224

222225
int maxC = Math.max(coords[1], coords[3]);
223226
int sz = (maxC+"").length();
224-
String formatC = "%" + sz + "d "; // S Coord CAS548 remove S and N
227+
String formatC = "%" + sz + "d ";
225228
String formatM = "%" + sz + "s ";
226229

227230
int inc = 60; // output in rows of 60
@@ -279,7 +282,7 @@ public void actionPerformed(ActionEvent arg0) {
279282
reverseAlign();
280283
}
281284
});
282-
JButton trimButton = Jcomp.createButton("No trim", "Align without trimming"); // CAS563 added this option
285+
JButton trimButton = Jcomp.createButton("No trim", "Align without trimming");
283286
trimButton.addActionListener(new ActionListener() {
284287
public void actionPerformed(ActionEvent arg0) {
285288
trimButton.setEnabled(false); // the data structures is reused and changed
@@ -370,7 +373,7 @@ private void reverseAlign() {
370373
}
371374

372375
/*************************************************************
373-
* toggle all hits and merged hits; CAS560 add
376+
* toggle all hits and merged hits;
374377
*/
375378
private void runMerge() {
376379
String queryShow = SeqDataInfo.calcMergeHits(Globals.Q, queryHits, false);
@@ -381,7 +384,7 @@ private void runMerge() {
381384
queryShow, targetShow, isQuery, isInvHit, true);
382385
}
383386
/*************************************************************
384-
* retain target ordered by query - the '#' will be out-of-order; CAS560 add
387+
* retain target ordered by query - the '#' will be out-of-order;
385388
*/
386389
private void runOrder() {
387390
new TextShowInfo(alignPool, hitDataObj, titleOrder + " " + title,

0 commit comments

Comments
 (0)