Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PeakStrainer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
labShevchenko
PeakStrainer
Commits
3d8fc7ab
Commit
3d8fc7ab
authored
5 years ago
by
mirandaa
Browse files
Options
Downloads
Patches
Plain Diff
fix: new strategy to get low
parent
99601dd4
Branches
velos_on_miranda
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/simStitching/simStitcher.py
+13
-24
13 additions, 24 deletions
lib/simStitching/simStitcher.py
with
13 additions
and
24 deletions
lib/simStitching/simStitcher.py
+
13
−
24
View file @
3d8fc7ab
...
@@ -23,8 +23,7 @@ class Scan(object):
...
@@ -23,8 +23,7 @@ class Scan(object):
def
__init__
(
self
,
filterline
):
def
__init__
(
self
,
filterline
):
self
.
filterline
=
filterline
self
.
filterline
=
filterline
self
.
match
=
re
.
match
(
r
'
(.*)\[(\d+\.\d*)-(\d+\.\d*)\]
'
,
filterline
)
self
.
match
=
re
.
match
(
r
'
(.*) (\d+\.\d+)@(.*)\[(\d+\.\d*)-(\d+\.\d*)\]
'
,
filterline
)
self
.
__low
=
None
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
filterline
return
self
.
filterline
...
@@ -35,15 +34,14 @@ class Scan(object):
...
@@ -35,15 +34,14 @@ class Scan(object):
def
_head
(
self
):
def
_head
(
self
):
return
self
.
match
.
group
(
1
)
return
self
.
match
.
group
(
1
)
def
_low
(
self
):
def
_low
(
self
):
self
.
__low
=
float
(
self
.
match
.
group
(
2
))
low
=
self
.
_target
()
-
abs
(
self
.
_high
()
-
self
.
_target
(
))
return
self
.
__
low
return
low
def
_high
(
self
):
def
_high
(
self
):
return
float
(
self
.
match
.
group
(
3
))
return
float
(
self
.
match
.
group
(
5
))
def
_center
(
self
):
def
_center
(
self
):
return
(
float
(
self
.
match
.
group
(
2
))
+
float
(
self
.
match
.
group
(
3
))
)
/
2
return
(
float
(
self
.
match
.
group
(
4
))
+
float
(
self
.
match
.
group
(
5
))
)
/
2
def
_target
(
self
):
def
_target
(
self
):
m
=
re
.
match
(
r
'
.* (\d+\.\d+)@
'
,
self
.
_head
())
return
float
(
self
.
match
.
group
(
2
))
return
float
(
m
.
group
(
1
))
def
asTuple
(
self
):
def
asTuple
(
self
):
return
(
self
.
_head
(),
self
.
_low
(),
self
.
_high
())
return
(
self
.
_head
(),
self
.
_low
(),
self
.
_high
())
...
@@ -118,7 +116,7 @@ class Scan(object):
...
@@ -118,7 +116,7 @@ class Scan(object):
def
overlapLow
(
self
):
def
overlapLow
(
self
):
if
self
.
previous
is
None
or
self
.
filterLine
.
_head
()
!=
self
.
previous
.
filterLine
.
_head
():
# use the difference in high
if
self
.
previous
is
None
or
self
.
filterLine
.
_head
()
!=
self
.
previous
.
filterLine
.
_head
():
# use the difference in high
return
self
.
filterLine
.
_low
()
+
self
.
_getHighOverlap
()
return
self
.
filterLine
.
_low
()
+
self
.
_getHighOverlap
()
else
:
else
:
return
self
.
filterLine
.
_low
()
+
self
.
_getLowOverlap
()
return
self
.
filterLine
.
_low
()
+
self
.
_getLowOverlap
()
...
@@ -198,7 +196,7 @@ def getMatchingMS(sampleSimPeaks, scans_ms):
...
@@ -198,7 +196,7 @@ def getMatchingMS(sampleSimPeaks, scans_ms):
def
toCSVFile
(
fileBaseName
,
dictOrList
):
def
toCSVFile
(
fileBaseName
,
dictOrList
):
with
file
(
fileBaseName
+
'
.csv
'
,
'
w
b
'
)
as
outfile
:
with
open
(
fileBaseName
+
'
.csv
'
,
'
w
'
)
as
outfile
:
if
type
(
dictOrList
)
is
list
:
if
type
(
dictOrList
)
is
list
:
string
=
'
\n
'
.
join
(
map
(
str
,
dictOrList
))
string
=
'
\n
'
.
join
(
map
(
str
,
dictOrList
))
string
=
string
.
replace
(
'
(
'
,
''
)
string
=
string
.
replace
(
'
(
'
,
''
)
...
@@ -374,13 +372,6 @@ def getSelectedMatchingSim(matchingSim):
...
@@ -374,13 +372,6 @@ def getSelectedMatchingSim(matchingSim):
return
selected
return
selected
def
velosAdapt
(
scan
):
target
=
scan
.
filterLine
.
_target
()
high
=
scan
.
filterLine
.
_high
()
delta
=
abs
(
high
-
target
)
scan
.
filterLine
.
__low
=
target
-
delta
return
scan
def
simStitcher
(
filePath
,
scaleToCenterMass
=
True
,
adaptByRegresion
=
False
,
daltons
=
5
,
csvPath1
=
None
,
loglevel
=
3
):
def
simStitcher
(
filePath
,
scaleToCenterMass
=
True
,
adaptByRegresion
=
False
,
daltons
=
5
,
csvPath1
=
None
,
loglevel
=
3
):
'''
'''
...
@@ -410,11 +401,7 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
...
@@ -410,11 +401,7 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
log
.
debug
(
'
\n
'
.
join
(
map
(
str
,
scans_mzxml_sim
)))
log
.
debug
(
'
\n
'
.
join
(
map
(
str
,
scans_mzxml_sim
)))
if
loglevel
>
2
:
toCSVFile
(
csvPath
+
'
scans_mzxml_sim
'
,
scans_mzxml_sim
)
if
loglevel
>
2
:
toCSVFile
(
csvPath
+
'
scans_mzxml_sim
'
,
scans_mzxml_sim
)
scans_og
=
[
Scan
(
*
scan_xml
)
for
scan_xml
in
scans_mzxml_sim
]
scans
=
[
Scan
(
*
scan_xml
)
for
scan_xml
in
scans_mzxml_sim
]
log
.
warning
(
'
adapting values to Velos format
'
)
scans
=
[
velosAdapt
(
s
)
for
s
in
scans_og
]
log
.
info
(
'
get sorted filterlines
'
)
# where low is a number instead of a text
log
.
info
(
'
get sorted filterlines
'
)
# where low is a number instead of a text
scans
.
sort
(
key
=
lambda
scan
:
scan
.
filterLine
.
asTuple
())
scans
.
sort
(
key
=
lambda
scan
:
scan
.
filterLine
.
asTuple
())
...
@@ -434,8 +421,10 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
...
@@ -434,8 +421,10 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
#-- build stitched scans
#-- build stitched scans
scans_stitched
=
{}
scans_stitched
=
{}
HEAD_ADD
=
'
999.99@cid0.00
'
for
scan
in
scans
:
for
scan
in
scans
:
head
=
scan
.
filterLine
.
_head
()
head
=
scan
.
filterLine
.
_head
()
head
+=
HEAD_ADD
masses
,
intens
=
scan
.
nonOverlap_andNoEdgePeaks
(
daltons
)
masses
,
intens
=
scan
.
nonOverlap_andNoEdgePeaks
(
daltons
)
totIonCounts
=
[
scan
.
totalIonCount
()]
*
len
(
masses
)
totIonCounts
=
[
scan
.
totalIonCount
()]
*
len
(
masses
)
heads
=
[
scan
.
filterLine
]
*
len
(
masses
)
heads
=
[
scan
.
filterLine
]
*
len
(
masses
)
...
@@ -453,8 +442,8 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
...
@@ -453,8 +442,8 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
names
=
list
(
scans_stitched
.
keys
())
names
=
list
(
scans_stitched
.
keys
())
# -- rename
# -- rename
for
stitched_Head
in
names
:
for
stitched_Head
in
names
:
min_head
=
min
([
scan
.
filterLine
.
_low
()
for
scan
in
scans
if
scan
.
filterLine
.
_head
()
==
stitched_Head
])
min_head
=
min
([
scan
.
filterLine
.
_low
()
for
scan
in
scans
if
scan
.
filterLine
.
_head
()
+
HEAD_ADD
==
stitched_Head
])
max_head
=
max
([
scan
.
filterLine
.
_high
()
for
scan
in
scans
if
scan
.
filterLine
.
_head
()
==
stitched_Head
])
max_head
=
max
([
scan
.
filterLine
.
_high
()
for
scan
in
scans
if
scan
.
filterLine
.
_head
()
+
HEAD_ADD
==
stitched_Head
])
rename
=
stitched_Head
+
'
[
'
+
str
(
min_head
)
+
'
-
'
+
str
(
max_head
)
+
'
]
'
rename
=
stitched_Head
+
'
[
'
+
str
(
min_head
)
+
'
-
'
+
str
(
max_head
)
+
'
]
'
scans_stitched
[
rename
]
=
scans_stitched
[
stitched_Head
]
scans_stitched
[
rename
]
=
scans_stitched
[
stitched_Head
]
del
scans_stitched
[
stitched_Head
]
del
scans_stitched
[
stitched_Head
]
...
...
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