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
b1c4e031
Commit
b1c4e031
authored
8 years ago
by
Wai Yi Leung
Browse files
Options
Downloads
Patches
Plain Diff
A bit refactoring on the variable names
parent
eea29773
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
public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/BamUtils.scala
+8
-5
8 additions, 5 deletions
...s/src/main/scala/nl/lumc/sasc/biopet/utils/BamUtils.scala
with
8 additions
and
5 deletions
public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/BamUtils.scala
+
8
−
5
View file @
b1c4e031
...
...
@@ -73,7 +73,9 @@ object BamUtils {
val
insertsizes
:
List
[
Int
]
=
(
for
{
read
<-
samIterator
.
toStream
.
takeWhile
(
rec
=>
{
// TODO: This value is now hard-coded. I'm not sure whether this is the best practice on selecting reads with a minimum required quality.
val
minQ10
=
rec
.
getMappingQuality
>=
10
// with properPairFlag we exclude readpairs that span multiple contigs.
val
paired
=
rec
.
getReadPairedFlag
&&
rec
.
getProperPairFlag
val
bothMapped
=
if
(
paired
)
((
rec
.
getReadUnmappedFlag
==
false
)
&&
(
rec
.
getMateUnmappedFlag
==
false
))
else
false
paired
&&
bothMapped
&&
minQ10
...
...
@@ -81,11 +83,11 @@ object BamUtils {
}
yield
{
read
.
getInferredInsertSize
.
asInstanceOf
[
Int
].
abs
})(
collection
.
breakOut
)
val
cti
=
insertsizes
.
foldLeft
((
0.0
,
0
))((
t
,
r
)
=>
(
t
.
_1
+
r
,
t
.
_2
+
1
))
val
lociInsertSize
=
insertsizes
.
foldLeft
((
0.0
,
0
))((
t
,
r
)
=>
(
t
.
_1
+
r
,
t
.
_2
+
1
))
samIterator
.
close
()
inputSam
.
close
()
if
(
cti
.
_2
==
0
)
None
else
Some
((
cti
.
_1
/
cti
.
_2
).
toInt
)
if
(
lociInsertSize
.
_2
==
0
)
None
else
Some
((
lociInsertSize
.
_1
/
lociInsertSize
.
_2
).
toInt
)
}).
toList
.
flatten
val
contigInsertSize
=
insertSizesOnAllFragments
.
foldLeft
((
0.0
,
0
))((
t
,
r
)
=>
(
t
.
_1
+
r
,
t
.
_2
+
1
))
...
...
@@ -95,16 +97,17 @@ object BamUtils {
/**
* Estimate the insertsize for one single bamfile and return the insertsize
*
* @param bamFile bamfile to estimate av
g
insertsize from
* @param bamFile bamfile to estimate av
erage
insertsize from
* @return
*/
def
sampleBamInsertSize
(
bamFile
:
File
,
samplingSize
:
Int
=
10000
,
binSize
:
Int
=
1000000
)
:
Int
=
{
val
inputSam
:
SamReader
=
SamReaderFactory
.
makeDefault
.
open
(
bamFile
)
val
bam
i
nsert
s
izes
=
inputSam
.
getFileHeader
.
getSequenceDictionary
.
getSequences
.
par
.
map
({
val
bam
I
nsert
S
izes
=
inputSam
.
getFileHeader
.
getSequenceDictionary
.
getSequences
.
par
.
map
({
contig
=>
BamUtils
.
contigInsertSize
(
bamFile
,
contig
.
getSequenceName
,
1
,
contig
.
getSequenceLength
,
samplingSize
,
binSize
)
}).
toList
val
counts
=
bam
i
nsert
s
izes
.
flatMap
(
x
=>
x
)
val
counts
=
bam
I
nsert
S
izes
.
flatMap
(
x
=>
x
)
// avoid division by zero
if
(
counts
.
size
!=
0
)
{
counts
.
sum
/
counts
.
size
}
else
{
...
...
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