Skip to content

Commit

Permalink
mv gs pb files back to here due to RGLab/cytolib#45
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejiang committed Jan 21, 2021
1 parent 1dba442 commit 7348e4e
Show file tree
Hide file tree
Showing 10 changed files with 26,920 additions and 10 deletions.
24 changes: 22 additions & 2 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ pbCxxFlags <- function() {
# Return the linker flags requried for pb on this platform
pbLdFlags <- function() {
lite = FALSE
# gslibs <- system.file(file.path("lib", "GatingSet.pb.o"), package = "RProtoBufLib")
# on Windows and Solaris we need to explicitly link against pb.dll
if ((Sys.info()['sysname'] %in% c("Windows", "SunOS")) && !isSparc()) {
suffix <- ifelse(lite, "-lite", "")
pb <- pbLibPath(suffix)
res <- asBuildPath(pb)
gs <- gsLibPath()
# res <- asBuildPath(pb)
res <- paste("-L", asBuildPath(dirname(pb)), asBuildPath(dirname(gs)), " -lprotobuf -lGatingSet.pb", sep = "")
} else {
res <- ""
}
Expand Down Expand Up @@ -71,6 +72,25 @@ pbLibPath <- function(suffix = "") {
}
}

gsLibPath <- function(suffix = "") {
sysname <- Sys.info()['sysname']
pbSupported <- list(
"Darwin" = paste("libGatingSet.pb", suffix, ".dylib", sep = ""),
"Linux" = paste("libGatingSet.pb", suffix, ".so", sep = ""),
"Windows" = paste("libGatingSet.pb", suffix, ".dll", sep = ""),
"SunOS" = paste("libGatingSet.pb", suffix, ".so", sep = "")
)
# browser()
if ((sysname %in% names(pbSupported)) && !isSparc()) {
libDir <- "lib/"
if (sysname == "Windows")
libDir <- paste(libDir, .Platform$r_arch, "/", sep="")
system.file(paste(libDir, pbSupported[[sysname]], sep = ""),
package = "RProtoBufLib")
} else {
NULL
}
}

isSparc <- function() {
Sys.info()['sysname'] == "SunOS" && Sys.info()[["machine"]] != "i86pc"
Expand Down
18 changes: 13 additions & 5 deletions R/hooks.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ dllInfo <- NULL
}
}

# load the package library
# library.dynam("RProtoBufLib", pkgname, libname)

gs <- gsLibPath()
if (!is.null(gs)) {
if (!file.exists(gs)) {
warning(paste("libGatingSet.pb library", gs, "not found."))
} else {
dllInfo <<- c(dllInfo, dyn.load(gs, local = FALSE, now = TRUE))
}
}

}

.onUnload <- function(libpath) {
Expand All @@ -24,6 +30,8 @@ dllInfo <- NULL
# library.dynam.unload("RProtoBufLib", libpath)

# unload dll if we loaded it
if (!is.null(dllInfo))
dyn.unload(dllInfo[["path"]])
for(dll in dllInfo)
if (!is.null(dll))
dyn.unload(dll[["path"]])

}
3 changes: 2 additions & 1 deletion cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

rm -f config.*
rm -rf src/pb_build
rm -rf src/protobuf-3.10.0
rm -rf src/protobuf-3.13.0
rm -f src/GatingSet_pb_lib/*.o
rm -f src/Makevars
rm -f src/*.o
rm -f src/*.so
10 changes: 10 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
2.1.4
-------------------------
1. build shared protobuf library instead of static
2. load libprotobuf globally on .onLoad

First release
-------------------------

bundle the protobuf c++ library and expose its headers and static libraries

258 changes: 258 additions & 0 deletions inst/include/GatingSet.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
syntax = "proto2";
package pb;
message paramRange{
required string name = 1;
required float min = 2;
required float max = 3;
}
message rangeGate{
required paramRange param = 1;
}
message paramPoly{
repeated string params = 1;//params.at(0) is x, params.at(1) is y axis
repeated coordinate vertices = 2;
}
message polygonGate{
required paramPoly param = 1;
optional quadGate qg = 2;

}
message coordinate{
required float x = 1;
required float y = 2;

}
message ellipseGate{
required coordinate mu = 1;// center point
repeated coordinate cov = 2;//covariance matrix
repeated coordinate antipodal_vertices = 3;
optional float dist = 4;
}
message BOOL_GATE_OP{
repeated string path = 1;
required uint32 op = 2;
required bool isNot =3;
}

message boolGate{
repeated BOOL_GATE_OP boolOpSpec = 1;//the gatePaths with the their logical operators
}

message clusterGate{
required string cluster_method = 1;
}
enum QUADRANT{
Q1 = 1;//-+
Q2 = 2;//++
Q3 = 3;//+-
Q4 = 4;//--

};
message quadGate{
required string uid = 1;
required QUADRANT quadrant = 3;
}
enum GATE_TYPE{
POLYGON_GATE = 1;
RANGE_GATE = 2;
BOOL_GATE = 3;
ELLIPSE_GATE = 4;
RECT_GATE = 5;
LOGICAL_GATE = 6;
ELLIPSOID_GATE = 7;
CLUSTER_GATE = 8;
QUAD_GATE = 9;
}
message gate{
required bool neg =1;
required bool isTransformed =2;
required bool isGained = 3;
required GATE_TYPE type = 4;

optional rangeGate rg = 5;
optional polygonGate pg = 6;
optional ellipseGate eg = 7;
optional boolGate bg = 8;
optional clusterGate cg = 9;

}


message POPSTATS{
required string statType = 1;
required float statVal = 2;
}
enum ind_type {
BOOL = 0;
INT = 1;
ROOT = 2 ;
}
message calibrationTable{
repeated float x = 1 [packed = true];
repeated float y = 2 [packed = true];
repeated float b = 3 [packed = true];
repeated float c = 4 [packed = true];
repeated float d = 5 [packed = true];
optional uint32 spline_method = 6;
optional string caltype = 7;
optional bool flag = 8;
}
enum TRANS_TYPE {
PB_CALTBL = 0;
PB_LOG = 1 ;
PB_LIN = 2;
PB_FLIN = 3;
PB_FASIGNH = 4;
PB_BIEXP = 5;
PB_LOGICLE = 6;
PB_LOGGML2 = 7;
PB_SCALE = 8;
}
message biexpTrans{
optional uint32 channelRange = 1;
optional float pos = 2;
optional float neg = 3;
optional float widthBasis = 4;
optional float maxValue = 5;
}
message fasinhTrans{
optional float length = 1;
optional float maxRange= 2;
optional float T = 3;
optional float A = 4;
optional float M = 5;;
}
message scaleTrans{
optional float scale_factor = 1;
optional float t_scale = 2;
optional float r_scale = 3;
}
message flinTrans{
optional float min = 1;
optional float max = 2;
}
message logTrans{
optional float offset = 1;
optional float decade = 2;
optional float T = 3;
optional float scale = 4;
}
message logGML2Trans{
optional float T = 1;
optional float M = 2;
}
message logicleTrans{
optional float T = 1;
optional float W= 2;
optional float M = 3;
optional float A = 4;
optional float bins = 5;
optional bool isGml2 = 6;
optional bool isInverse = 7;

}
message transformation{
optional calibrationTable calTbl = 1;
optional bool isGateOnly = 2;
optional string name = 4;
optional string channel = 5;
optional bool isComputed = 6;
optional uint32 type = 12;
optional TRANS_TYPE trans_type = 3; //used to handle polymorphism
optional biexpTrans bt = 7;
optional logTrans lt = 8;
optional flinTrans flt = 9;
optional scaleTrans st = 10;
optional fasinhTrans ft = 11;
optional logicleTrans lgt = 13;
optional logGML2Trans lgml2t = 14;
}

message trans_pair{
required string name = 1;
optional uint64 trans_address = 2;//legacy
optional transformation trans = 3;
}

message trans_local{
repeated trans_pair tp = 1;
optional string groupName = 2;
repeated uint32 sampleIDs = 3 [packed = true];
}

message POPINDICES{
required uint32 nEvents = 1;
required ind_type indtype = 2;
repeated uint32 iInd = 3 [packed = true];
optional bytes bInd = 4;//bits packaged into bytes
}

message nodeProperties{
required string thisName = 1;
repeated POPSTATS fjStats = 2;
repeated POPSTATS fcStats = 3;
required bool hidden = 4;
optional POPINDICES indices = 5;
optional gate thisGate = 6;

}

message treeNodes {
required nodeProperties node = 1;
optional uint32 parent = 2;
}

message populationTree{
repeated treeNodes node = 1;

}
message COMP{
optional string cid = 1;
optional string prefix = 2;
optional string suffix = 3;
optional string name = 4;
optional string comment = 5;
repeated string marker = 6;
repeated float spillOver = 7;
}
message PARAM{
optional string param = 1;
optional bool log = 2;
optional uint32 range = 3;
optional uint32 highValue = 4;
optional uint32 calibrationIndex = 5;
//optional float timestep = 6;
}
message GatingHierarchy {
required populationTree tree = 2;

optional COMP comp = 1;
optional bool isLoaded = 3;

repeated PARAM transFlag = 4;
optional trans_local trans = 5;
optional CytoFrame frame = 6;
}
message CytoFrame {
required bool is_h5 = 1;
}

//legacy
message TRANS_TBL{
optional uint64 trans_address = 1;
optional transformation trans = 2;
}

message GatingSet {
repeated TRANS_TBL trans_tbl = 2;//legacy
repeated string sampleName = 1; //a view of ghs
optional uint64 globalBiExpTrans = 3;//address of globalBiExpTrans, the actual object stored in trans_tbl
optional uint64 globalLinTrans = 4;//address of globalLinTrans, the actual object stored in trans_tbl
repeated trans_local gTrans = 5;
optional string guid = 6;
optional string cytolib_verion = 7;
optional string pb_verion = 8;
optional string h5_verion = 9;
// repeated gh_tbl ghs = 7;//gh is separately stored due to the size limit of pb message
}

Loading

0 comments on commit 7348e4e

Please sign in to comment.