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
a913c55e
Commit
a913c55e
authored
Feb 16, 2015
by
bow
Browse files
Refactor syncIter logic
parent
922b3949
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala
View file @
a913c55e
...
...
@@ -128,25 +128,23 @@ object FastqSync extends ToolCommand {
(
pre
.
headOption
,
seqA
.
headOption
,
seqB
.
headOption
)
match
{
// where the magic happens!
case
(
Some
(
r
),
Some
(
a
),
Some
(
b
))
=>
// value of A iterator in the next recursion
val
nextA
=
// hold A if its head is not equal to reference
if
(
a
.
fragId
!=
r
.
fragId
)
{
if
(
b
.
fragId
==
r
.
fragId
)
numDiscB
+=
1
seqA
// otherwise, go to next item
}
else
seqA
.
tail
// like A above
val
nextB
=
if
(
b
.
fragId
!=
r
.
fragId
)
{
if
(
a
.
fragId
==
r
.
fragId
)
numDiscA
+=
1
seqB
}
else
seqB
.
tail
// write only if all IDs are equal
if
(
a
.
fragId
==
r
.
fragId
&&
b
.
fragId
==
r
.
fragId
)
{
numKept
+=
1
seqOutA
.
write
(
a
)
seqOutB
.
write
(
b
)
val
(
nextA
,
nextB
)
=
(
a
.
fragId
==
r
.
fragId
,
b
.
fragId
==
r
.
fragId
)
match
{
// all IDs are equal to ref
case
(
true
,
true
)
=>
numKept
+=
1
seqOutA
.
write
(
a
)
seqOutB
.
write
(
b
)
(
seqA
.
tail
,
seqB
.
tail
)
// B not equal to ref and A is equal, then we discard A and progress
case
(
true
,
false
)
=>
numDiscA
+=
1
(
seqA
.
tail
,
seqB
)
// A not equal to ref and B is equal, then we discard B and progress
case
(
false
,
true
)
=>
numDiscB
+=
1
(
seqA
,
seqB
.
tail
)
case
(
false
,
false
)
=>
(
seqA
,
seqB
)
}
syncIter
(
pre
.
tail
,
nextA
,
nextB
)
// recursion base case: both iterators have been exhausted
...
...
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