Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
biopet.biopet
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
biopet.biopet
Commits
123e830e
Commit
123e830e
authored
10 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
Added constructor and moved Lazy variables in 1 function
parent
b975df6e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Ln.scala
+48
-38
48 additions, 38 deletions
...rk/src/main/scala/nl/lumc/sasc/biopet/extensions/Ln.scala
with
48 additions
and
38 deletions
biopet-framework/src/main/scala/nl/lumc/sasc/biopet/extensions/Ln.scala
+
48
−
38
View file @
123e830e
...
...
@@ -18,52 +18,52 @@ class Ln(val root: Configurable) extends InProcessFunction with Configurable {
var
relative
:
Boolean
=
true
private
lazy
val
inCanonical
:
String
=
{
// need to remove "/~" to correctly expand path with tilde
in
.
getCanonicalPath
().
replace
(
"/~"
,
""
)
}
lazy
val
cmd
:
String
=
{
lazy
val
inCanonical
:
String
=
{
// need to remove "/~" to correctly expand path with tilde
in
.
getCanonicalPath
().
replace
(
"/~"
,
""
)
}
private
lazy
val
outCanonical
:
String
=
{
out
.
getCanonicalPath
().
replace
(
"/~"
,
""
)
}
lazy
val
outCanonical
:
String
=
{
out
.
getCanonicalPath
().
replace
(
"/~"
,
""
)
}
private
lazy
val
inToks
:
Array
[
String
]
=
{
inCanonical
.
split
(
File
.
separator
)
}
lazy
val
inToks
:
Array
[
String
]
=
{
inCanonical
.
split
(
File
.
separator
)
}
private
lazy
val
outToks
:
Array
[
String
]
=
{
outCanonical
.
split
(
File
.
separator
)
}
lazy
val
outToks
:
Array
[
String
]
=
{
outCanonical
.
split
(
File
.
separator
)
}
private
lazy
val
commonPrefixLength
:
Int
=
{
val
maxLength
=
scala
.
math
.
min
(
inToks
.
length
,
outToks
.
length
)
var
i
:
Int
=
0
;
while
(
i
<
maxLength
&&
inToks
(
i
)
==
outToks
(
i
))
i
+=
1
;
i
}
lazy
val
commonPrefixLength
:
Int
=
{
val
maxLength
=
scala
.
math
.
min
(
inToks
.
length
,
outToks
.
length
)
var
i
:
Int
=
0
;
while
(
i
<
maxLength
&&
inToks
(
i
)
==
outToks
(
i
))
i
+=
1
;
i
}
private
lazy
val
inUnique
:
String
=
{
inToks
.
slice
(
commonPrefixLength
,
inToks
.
length
).
mkString
(
File
.
separator
)
}
lazy
val
inUnique
:
String
=
{
inToks
.
slice
(
commonPrefixLength
,
inToks
.
length
).
mkString
(
File
.
separator
)
}
private
lazy
val
outUnique
:
String
=
{
outToks
.
slice
(
commonPrefixLength
,
outToks
.
length
).
mkString
(
File
.
separator
)
}
lazy
val
outUnique
:
String
=
{
outToks
.
slice
(
commonPrefixLength
,
outToks
.
length
).
mkString
(
File
.
separator
)
}
private
lazy
val
inRelative
:
String
=
{
// calculate 'distance' from output directory to input
// which is the number of directory walks required to get to the inUnique directory from outDir
val
outDir
=
FilenameUtils
.
getFullPathNoEndSeparator
(
outUnique
)
val
dist
:
Int
=
scala
.
math
.
max
(
0
,
outDir
.
split
(
File
.
separator
).
length
-
1
)
val
result
=
if
(
dist
>
0
)
((
".."
+
File
.
separator
)
*
dist
)
+
File
.
separator
+
inUnique
else
inUnique
result
}
lazy
val
inRelative
:
String
=
{
// calculate 'distance' from output directory to input
// which is the number of directory walks required to get to the inUnique directory from outDir
val
outDir
=
FilenameUtils
.
getFullPathNoEndSeparator
(
outUnique
)
val
dist
:
Int
=
scala
.
math
.
max
(
0
,
outDir
.
split
(
File
.
separator
).
length
-
1
)
val
result
=
if
(
dist
>
0
)
((
".."
+
File
.
separator
)
*
dist
)
+
File
.
separator
+
inUnique
else
inUnique
result
}
lazy
val
cmd
:
String
=
{
if
(
relative
)
{
// workaround until we have `ln` that works with relative path (i.e. `ln -r`)
"ln -s "
+
inRelative
+
" "
+
outCanonical
...
...
@@ -77,3 +77,13 @@ class Ln(val root: Configurable) extends InProcessFunction with Configurable {
System
.
out
.
println
(
"cmd: '"
+
cmd
+
"', exitcode: "
+
process
.
exitValue
)
}
}
object
Ln
{
def
apply
(
root
:
Configurable
,
input
:
File
,
output
:
File
,
relative
:
Boolean
=
true
)
:
Ln
=
{
val
ln
=
new
Ln
(
root
)
ln
.
in
=
input
ln
.
out
=
output
ln
.
relative
=
relative
return
ln
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment