Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
e062f718
Commit
e062f718
authored
Jan 27, 2017
by
Peter van 't Hof
Browse files
Adding more tables
parent
b1191ca3
Changes
6
Hide whitespace changes
Inline
Side-by-side
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/SummaryToSqlite.scala
View file @
e062f718
...
...
@@ -2,41 +2,61 @@ package nl.lumc.sasc.biopet.tools
import
java.io.File
import
nl.lumc.sasc.biopet.utils.summary.db.
{
Libraries
,
Samples
}
import
slick.driver.H2Driver.api._
import
scala.concurrent.ExecutionContext.Implicits.global
import
nl.lumc.sasc.biopet.utils.
{
ConfigUtils
,
ToolCommand
}
import
scala.concurrent.Await
import
scala.concurrent.duration.Duration
/**
* Created by pjvanthof on 26/01/2017.
*/
object
SummaryToSqlite
extends
ToolCommand
{
case
class
Args
(
inputJson
:
File
=
null
,
outputHdf5
:
File
=
null
)
extends
AbstractArgs
outputSqlite
:
File
=
null
,
force
:
Boolean
=
false
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'I'
,
"inputJson"
)
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
inputJson
=
x
)
}
text
"Input json file"
opt
[
File
](
'o'
,
"outputHdf5"
)
required
()
maxOccurs
1
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
output
Hdf5
=
x
)
c
.
copy
(
output
Sqlite
=
x
)
}
text
"Output hdf5 file"
opt
[
Unit
](
'f'
,
"force"
)
action
{
(
x
,
c
)
=>
c
.
copy
(
force
=
true
)
}
text
"If database already exist it will be moved"
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
argsParser
=
new
OptParser
val
cmdArgs
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
)
logger
.
info
(
"Start"
)
val
jsonMap
=
ConfigUtils
.
fileToConfigMap
(
cmdArgs
.
inputJson
)
val
db
=
Database
.
forURL
(
s
"jdbc:sqlite:${cmdArgs.outputHdf5.getAbsolutePath}"
,
driver
=
"org.sqlite.JDBC"
)
if
(
cmdArgs
.
outputSqlite
.
exists
())
{
if
(
cmdArgs
.
force
)
cmdArgs
.
outputSqlite
.
delete
()
else
throw
new
IllegalArgumentException
(
s
"Db already exist: ${cmdArgs.outputSqlite}"
)
}
try
{
val
db
=
Database
.
forURL
(
s
"jdbc:sqlite:${cmdArgs.outputSqlite.getAbsolutePath}"
,
driver
=
"org.sqlite.JDBC"
)
try
{
val
samples
=
TableQuery
[
Samples
]
val
libraries
=
TableQuery
[
Libraries
]
val
setup
=
DBIO
.
seq
(
(
samples
.
schema
++
libraries
.
schema
).
create
)
val
setupFuture
=
db
.
run
(
setup
)
Await
.
result
(
setupFuture
,
Duration
.
Inf
)
}
finally
db
.
close
logger
.
info
(
"Done"
)
}
}
biopet-utils/pom.xml
View file @
e062f718
...
...
@@ -36,9 +36,9 @@
<version>
3.1.1
</version>
</dependency>
<dependency>
<groupId>
org.
slf4j
</groupId>
<artifactId>
s
lf4j-nop
</artifactId>
<version>
1
.
6.
4
</version>
<groupId>
org.
xerial
</groupId>
<artifactId>
s
qlite-jdbc
</artifactId>
<version>
3.
16.
1
</version>
</dependency>
<dependency>
<groupId>
colt
</groupId>
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/Libraries.scala
0 → 100644
View file @
e062f718
package
nl.lumc.sasc.biopet.utils.summary.db
import
java.sql.Blob
import
slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 26-1-17.
*/
class
Libraries
(
tag
:
Tag
)
extends
Table
[(
Int
,
String
,
Int
,
Blob
)](
tag
,
"Libraries"
)
{
def
libraryId
=
column
[
Int
](
"libraryId"
,
O
.
PrimaryKey
)
// This is the primary key column
def
libraryName
=
column
[
String
](
"libraryName"
)
def
sampleId
=
column
[
Int
](
"sampleId"
)
def
tags
=
column
[
Blob
](
"tags"
)
// Every table needs a * projection with the same type as the table's type parameter
def
*
=
(
libraryId
,
libraryName
,
sampleId
,
tags
)
}
\ No newline at end of file
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/Pipelines.scala
0 → 100644
View file @
e062f718
package
nl.lumc.sasc.biopet.utils.summary.db
import
slick.driver.H2Driver.api._
/**
* Created by pjvanthof on 27/01/2017.
*/
class
Pipelines
(
tag
:
Tag
)
extends
Table
[(
Int
,
String
)](
tag
,
"Pipelines"
)
{
def
pipelineId
=
column
[
Int
](
"runId"
,
O
.
PrimaryKey
)
// This is the primary key column
def
pipelineName
=
column
[
String
](
"sampleName"
)
// Every table needs a * projection with the same type as the table's type parameter
def
*
=
(
pipelineId
,
pipelineName
)
}
\ No newline at end of file
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/Runs.scala
0 → 100644
View file @
e062f718
package
nl.lumc.sasc.biopet.utils.summary.db
import
slick.driver.H2Driver.api._
/**
* Created by pjvanthof on 27/01/2017.
*/
class
Runs
(
tag
:
Tag
)
extends
Table
[(
Int
,
String
)](
tag
,
"Runs"
)
{
def
runId
=
column
[
Int
](
"runId"
,
O
.
PrimaryKey
)
// This is the primary key column
def
runName
=
column
[
String
](
"sampleName"
)
// Every table needs a * projection with the same type as the table's type parameter
def
*
=
(
runId
,
runName
)
}
\ No newline at end of file
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/summary/db/Samples.scala
View file @
e062f718
package
nl.lumc.sasc.biopet.utils.summary.db
import
java.sql.Blob
import
slick.driver.H2Driver.api._
/**
* Created by pjvan_thof on 26-1-17.
*/
class
Samples
(
tag
:
Tag
)
extends
Table
[(
Int
,
String
)](
tag
,
"S
UPPLIERS
"
)
{
class
Samples
(
tag
:
Tag
)
extends
Table
[(
Int
,
String
,
Blob
)](
tag
,
"S
amples
"
)
{
def
sampleId
=
column
[
Int
](
"sampleId"
,
O
.
PrimaryKey
)
// This is the primary key column
def
sampleName
=
column
[
String
](
"sampleName"
)
def
tags
=
column
[
Blob
](
"tags"
)
// Every table needs a * projection with the same type as the table's type parameter
def
*
=
(
sampleId
,
sampleName
)
def
*
=
(
sampleId
,
sampleName
,
tags
)
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment