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
9428f738
Commit
9428f738
authored
9 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
Start on basecounter
parent
dc31e3e8
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/BaseCounter.scala
+52
-0
52 additions, 0 deletions
...rc/main/scala/nl/lumc/sasc/biopet/tools/BaseCounter.scala
with
52 additions
and
0 deletions
public/biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/BaseCounter.scala
0 → 100644
+
52
−
0
View file @
9428f738
package
nl.lumc.sasc.biopet.tools
import
java.io.File
import
htsjdk.samtools.
{
SAMRecord
,
SamReaderFactory
}
import
nl.lumc.sasc.biopet.utils.ToolCommand
import
nl.lumc.sasc.biopet.utils.intervals.
{
BedRecord
,
BedRecordList
}
import
scala.collection.JavaConversions._
import
scala.collection.mutable
/**
* Created by pjvanthof on 22/01/16.
*/
object
BaseCounter
extends
ToolCommand
{
case
class
Args
(
bedFile
:
File
=
null
,
outputDir
:
File
=
null
,
bamFile
:
File
=
null
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
"bedFile"
)
required
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
bedFile
=
x
)
}
opt
[
File
](
'o'
,
"outputDir"
)
required
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
outputDir
=
x
)
}
opt
[
File
](
'b'
,
"bam"
)
required
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
bamFile
=
x
)
}
}
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
argsParser
=
new
OptParser
val
cmdArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
(
""
))
val
bedrecords
=
BedRecordList
.
fromFile
(
cmdArgs
.
bedFile
).
combineOverlap
val
counts
=
for
(
region
<-
bedrecords
.
allRecords
)
yield
{
val
bamReader
=
SamReaderFactory
.
makeDefault
.
open
(
cmdArgs
.
bamFile
)
val
interval
=
region
.
toSamInterval
val
samIterator
=
bamReader
.
queryOverlapping
(
interval
.
getContig
,
interval
.
getStart
,
interval
.
getEnd
)
for
(
samRecord
<-
samIterator
)
samRecordToCounts
(
samRecord
,
region
.
originals
())
}
}
def
samRecordToCounts
(
samRecord
:
SAMRecord
,
bedRecords
:
List
[
BedRecord
])
:
Unit
=
{
samRecord
.
getAlignmentBlocks
.
foreach
{
x
=>
val
bedStart
=
x
.
getReferenceStart
-
1
val
bedEnd
=
bedStart
+
x
.
getLength
}
}
}
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