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
2b4cb228
Commit
2b4cb228
authored
10 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
Fix bugs on MergeAlleles
parent
c46b0592
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/tools/MergeAlleles.scala
+11
-6
11 additions, 6 deletions
...c/main/scala/nl/lumc/sasc/biopet/tools/MergeAlleles.scala
with
11 additions
and
6 deletions
biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/MergeAlleles.scala
+
11
−
6
View file @
2b4cb228
...
...
@@ -10,6 +10,8 @@ import htsjdk.variant.vcf.VCFFileReader
import
htsjdk.variant.vcf.VCFHeader
import
java.io.File
import
nl.lumc.sasc.biopet.core.ToolCommand
import
scala.collection.SortedMap
import
scala.collection.immutable.SortedSet
import
scala.collection.mutable.
{
Map
,
Set
}
import
scala.collection.JavaConversions._
...
...
@@ -37,6 +39,7 @@ object MergeAlleles extends ToolCommand {
val
argsParser
=
new
OptParser
val
commandArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
sys
.
exit
(
1
)
val
readers
=
commandArgs
.
inputFiles
.
map
(
new
VCFFileReader
(
_
,
true
))
val
referenceFile
=
new
FastaSequenceFile
(
commandArgs
.
reference
,
true
)
val
writer
=
new
AsyncVariantContextWriter
(
new
VariantContextWriterBuilder
().
setOutputFile
(
commandArgs
.
outputFile
).
build
)
val
header
=
new
VCFHeader
...
...
@@ -45,7 +48,6 @@ object MergeAlleles extends ToolCommand {
writer
.
writeHeader
(
header
)
for
(
chr
<-
referenceDict
.
getSequences
;
chunk
<-
(
0
to
(
chr
.
getSequenceLength
/
chunkSize
)))
{
val
readers
=
commandArgs
.
inputFiles
.
map
(
new
VCFFileReader
(
_
,
true
))
val
output
:
Map
[
Int
,
List
[
VariantContext
]]
=
Map
()
val
chrName
=
chr
.
getSequenceName
...
...
@@ -55,16 +57,18 @@ object MergeAlleles extends ToolCommand {
if
(
e
>
chr
.
getSequenceLength
)
chr
.
getSequenceLength
else
e
}
for
(
reader
<-
readers
.
par
;
variant
<-
reader
.
query
(
chrName
,
begin
,
end
))
{
for
(
reader
<-
readers
;
variant
<-
reader
.
query
(
chrName
,
begin
,
end
))
{
val
start
=
variant
.
getStart
if
(
output
.
contains
(
start
))
output
+=
variant
.
getStart
->
(
variant
::
output
(
start
))
else
output
+=
variant
.
getStart
->
List
(
variant
)
}
for
((
_
,
l
)
<-
output
)
{
writer
.
add
(
mergeAlleles
(
l
))
for
((
k
,
v
)
<-
SortedMap
(
output
.
toSeq
:
_
*
)
)
{
writer
.
add
(
mergeAlleles
(
v
))
}
}
writer
.
close
readers
.
foreach
(
_
.
close
)
}
def
mergeAlleles
(
records
:
List
[
VariantContext
])
:
VariantContext
=
{
...
...
@@ -73,7 +77,7 @@ object MergeAlleles extends ToolCommand {
for
(
a
<-
records
.
map
(
_
.
getReference
.
getBases
)
if
(
a
.
length
>
l
.
size
))
l
=
a
Allele
.
create
(
l
,
true
)
}
val
alleles
:
Set
[
Allele
]
=
Set
(
longestRef
)
val
alleles
:
Set
[
Allele
]
=
Set
()
val
builder
=
new
VariantContextBuilder
builder
.
chr
(
records
.
head
.
getChr
)
builder
.
start
(
records
.
head
.
getStart
)
...
...
@@ -85,7 +89,8 @@ object MergeAlleles extends ToolCommand {
for
(
r
<-
record
.
getAlternateAlleles
)
alleles
+=
Allele
.
create
(
r
.
getBaseString
+
suffix
)
}
}
builder
.
alleles
(
alleles
.
toSeq
)
builder
.
alleles
(
longestRef
::
alleles
.
toList
)
builder
.
computeEndFromAlleles
(
longestRef
::
alleles
.
toList
,
records
.
head
.
getStart
)
builder
.
make
}
}
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