Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDP Comparative Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
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
MSBio
TDP Comparative Tools
Commits
0ba31d4e
Commit
0ba31d4e
authored
2 years ago
by
Karen DRUART
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
b7503265
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
MGF2msAlign/mgf2msalign.py
+100
-0
100 additions, 0 deletions
MGF2msAlign/mgf2msalign.py
with
100 additions
and
0 deletions
MGF2msAlign/mgf2msalign.py
0 → 100644
+
100
−
0
View file @
0ba31d4e
# MGF2msAlign
# Created and translated from MATLAB
# by Kyowon Jeong, University of Tuebingen
# Initial version: April 21, 2022
import
sys
n
=
len
(
sys
.
argv
)
if
n
!=
4
:
print
(
'
Usage: python mgf2msalign.py [input mgf file] [output msalign file] [activation (CID, ETD, or HCD)]
'
)
sys
.
exit
()
mgf
=
sys
.
argv
[
1
]
msalign
=
sys
.
argv
[
2
]
act
=
sys
.
argv
[
3
]
file1
=
open
(
mgf
,
'
r
'
)
file2
=
open
(
msalign
,
'
w
'
)
Lines
=
file1
.
readlines
()
proton_mass
=
1.007276466621
class
Spec
:
id
=
1
def
__init__
(
self
,
act
):
self
.
mz
=
.
0
self
.
intensity
=
.
0
self
.
scan
=
0
self
.
activation
=
act
self
.
premz
=
.
0
self
.
preintensity
=
.
0
self
.
premass
=
.
0
self
.
precharge
=
0
self
.
rt
=
.
0
self
.
peaks
=
[]
def
addPeaks
(
self
,
str
):
tstr
=
str
.
split
(
'
'
)
tpeaks
=
[
float
(
tstr
[
0
]),
float
(
tstr
[
1
]),
int
(
tstr
[
2
][
0
:
-
1
])]
self
.
peaks
.
append
(
tpeaks
)
def
len
(
self
):
return
len
(
self
.
peaks
)
def
tomsalign
(
self
):
tstr
=
"
BEGIN IONS
\n
ID=
"
tstr
+=
str
(
Spec
.
id
)
tstr
+=
"
\n
SCANS=
"
tstr
+=
str
(
self
.
scan
)
tstr
+=
"
\n
ACTIVATION=
"
+
self
.
activation
tstr
+=
"
\n
PRECURSOR_MZ=
"
tstr
+=
str
(
self
.
premz
)
tstr
+=
"
\n
PRECURSOR_CHARGE=
"
tstr
+=
str
(
self
.
precharge
)
tstr
+=
"
\n
PRECURSOR_MASS=
"
tstr
+=
str
(
self
.
precharge
*
(
self
.
premz
-
proton_mass
))
tstr
+=
"
\n
PRECURSOR_INTENSITY=
"
tstr
+=
str
(
self
.
preintensity
)
tstr
+=
"
\n
RETENTION_TIME=
"
tstr
+=
str
(
self
.
rt
)
+
"
\n
"
for
peak
in
self
.
peaks
:
tstr
+=
str
(
peak
[
0
])
+
"
"
+
str
(
peak
[
1
])
+
"
"
+
str
(
peak
[
2
])
+
"
\n
"
tstr
+=
"
END IONS
\n
"
Spec
.
id
+=
1
return
tstr
spec
=
Spec
(
act
)
# Strips the newline character
for
line
in
Lines
:
if
not
line
:
break
line
=
line
.
strip
()
if
len
(
line
)
==
0
:
continue
elif
line
.
startswith
(
"
BEGIN IONS
"
):
# when a spec begins, reset all buffers
spec
=
Spec
(
act
)
elif
line
.
startswith
(
"
END IONS
"
):
# when a spec ends write to msalign
if
spec
.
len
()
>
0
:
file2
.
write
(
spec
.
tomsalign
())
elif
line
.
startswith
(
"
SCANS
"
):
spec
.
scan
=
int
(
line
.
split
(
"
=
"
)[
1
])
elif
line
.
startswith
(
"
RTINSECONDS
"
):
spec
.
rt
=
float
(
line
.
split
(
"
=
"
)[
1
])
elif
line
.
startswith
(
"
CHARGE
"
):
spec
.
precharge
=
int
(
line
.
split
(
"
=
"
)[
1
][
0
:
-
1
])
if
spec
.
precharge
==
0
:
spec
.
precharge
=
1
elif
line
.
startswith
(
"
PEPMASS
"
):
tstr
=
line
.
split
(
"
=
"
)[
1
].
split
(
'
'
)
spec
.
premz
=
float
(
tstr
[
0
])
spec
.
preintensity
=
float
(
tstr
[
1
])
elif
line
[
0
].
isdigit
():
spec
.
addPeaks
(
line
)
file2
.
close
()
file1
.
close
()
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