Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
PeakStrainer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
labShevchenko
PeakStrainer
Commits
3d8fc7ab
Commit
3d8fc7ab
authored
Feb 12, 2020
by
mirandaa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: new strategy to get low
parent
99601dd4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
24 deletions
+13
-24
lib/simStitching/simStitcher.py
lib/simStitching/simStitcher.py
+13
-24
No files found.
lib/simStitching/simStitcher.py
View file @
3d8fc7ab
...
...
@@ -23,8 +23,7 @@ class Scan(object):
def
__init__
(
self
,
filterline
):
self
.
filterline
=
filterline
self
.
match
=
re
.
match
(
r'(.*)\[(\d+\.\d*)-(\d+\.\d*)\]'
,
filterline
)
self
.
__low
=
None
self
.
match
=
re
.
match
(
r'(.*) (\d+\.\d+)@(.*)\[(\d+\.\d*)-(\d+\.\d*)\]'
,
filterline
)
def
__str__
(
self
):
return
self
.
filterline
...
...
@@ -35,15 +34,14 @@ class Scan(object):
def
_head
(
self
):
return
self
.
match
.
group
(
1
)
def
_low
(
self
):
self
.
__low
=
float
(
self
.
match
.
group
(
2
))
return
self
.
__
low
low
=
self
.
_target
()
-
abs
(
self
.
_high
()
-
self
.
_target
(
))
return
low
def
_high
(
self
):
return
float
(
self
.
match
.
group
(
3
))
return
float
(
self
.
match
.
group
(
5
))
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
):
m
=
re
.
match
(
r'.* (\d+\.\d+)@'
,
self
.
_head
())
return
float
(
m
.
group
(
1
))
return
float
(
self
.
match
.
group
(
2
))
def
asTuple
(
self
):
return
(
self
.
_head
(),
self
.
_low
(),
self
.
_high
())
...
...
@@ -118,7 +116,7 @@ class Scan(object):
def
overlapLow
(
self
):
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
:
return
self
.
filterLine
.
_low
()
+
self
.
_getLowOverlap
()
...
...
@@ -198,7 +196,7 @@ def getMatchingMS(sampleSimPeaks, scans_ms):
def
toCSVFile
(
fileBaseName
,
dictOrList
):
with
file
(
fileBaseName
+
'.csv'
,
'wb
'
)
as
outfile
:
with
open
(
fileBaseName
+
'.csv'
,
'w
'
)
as
outfile
:
if
type
(
dictOrList
)
is
list
:
string
=
'
\n
'
.
join
(
map
(
str
,
dictOrList
))
string
=
string
.
replace
(
'('
,
''
)
...
...
@@ -374,13 +372,6 @@ def getSelectedMatchingSim(matchingSim):
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
):
'''
...
...
@@ -410,11 +401,7 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
log
.
debug
(
'
\n
'
.
join
(
map
(
str
,
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
]
log
.
warning
(
'adapting values to Velos format'
)
scans
=
[
velosAdapt
(
s
)
for
s
in
scans_og
]
scans
=
[
Scan
(
*
scan_xml
)
for
scan_xml
in
scans_mzxml_sim
]
log
.
info
(
'get sorted filterlines'
)
# where low is a number instead of a text
scans
.
sort
(
key
=
lambda
scan
:
scan
.
filterLine
.
asTuple
())
...
...
@@ -434,8 +421,10 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
#-- build stitched scans
scans_stitched
=
{}
HEAD_ADD
=
' 999.99@cid0.00 '
for
scan
in
scans
:
head
=
scan
.
filterLine
.
_head
()
head
+=
HEAD_ADD
masses
,
intens
=
scan
.
nonOverlap_andNoEdgePeaks
(
daltons
)
totIonCounts
=
[
scan
.
totalIonCount
()]
*
len
(
masses
)
heads
=
[
scan
.
filterLine
]
*
len
(
masses
)
...
...
@@ -453,8 +442,8 @@ def simStitcher(filePath, scaleToCenterMass = True, adaptByRegresion = False , d
names
=
list
(
scans_stitched
.
keys
())
# -- rename
for
stitched_Head
in
names
:
min_head
=
min
([
scan
.
filterLine
.
_low
()
for
scan
in
scans
if
scan
.
filterLine
.
_head
()
==
stitched_Head
])
max_head
=
max
([
scan
.
filterLine
.
_high
()
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
()
+
HEAD_ADD
==
stitched_Head
])
rename
=
stitched_Head
+
'['
+
str
(
min_head
)
+
'-'
+
str
(
max_head
)
+
']'
scans_stitched
[
rename
]
=
scans_stitched
[
stitched_Head
]
del
scans_stitched
[
stitched_Head
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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