1
- package mzxml
1
+ package fr . inrae . p2m2 . mzxml
2
2
3
3
import com .lucidchart .open .xtract .{XmlReader , __ }
4
4
import com .lucidchart .open .xtract .XmlReader ._
5
5
import cats .syntax .all ._
6
- import mzxml .Precision .Value
7
6
import com .github .marklister .base64 .Base64 ._
7
+ import fr .inrae .p2m2 .mzxml
8
8
9
9
import java .nio ._
10
- import javax .xml .datatype .{DatatypeFactory , Duration }
11
- import scala .xml .NodeSeq
10
+ import javax .xml .datatype .DatatypeFactory
12
11
13
12
case class MzXML (
14
- msRun : mzxml. MsRun ,
13
+ msRun : MsRun ,
15
14
index : Seq [mzxml.IndexScan ] = Nil ,
16
15
indexOffset : Option [mzxml.IndexOffset ],
17
16
sha1 : Option [String ] = None
18
17
)
19
18
20
19
object MzXML {
21
20
implicit val reader : XmlReader [MzXML ] = (
22
- (__ \ " msRun" ).read[mzxml. MsRun ],
21
+ (__ \ " msRun" ).read[MsRun ],
23
22
(__ \ " index" ).read(seq[mzxml.IndexScan ]),
24
23
(__ \ " indexOffset" ).read[mzxml.IndexOffset ].optional,
25
24
attribute[String ](" sha1" ).optional
@@ -29,9 +28,9 @@ case class MsRun(
29
28
scanCount : Option [Int ],
30
29
startTimeInSeconds : Option [Int ],
31
30
endTimeInSeconds : Option [Int ],
32
- parentFile : Seq [mzxml. ParentFile ] = Nil ,
33
- msInstrument : Seq [mzxml. MsInstrument ] = Nil ,
34
- dataProcessing : Seq [mzxml. DataProcessing ] = Nil ,
31
+ parentFile : Seq [ParentFile ] = Nil ,
32
+ msInstrument : Seq [MsInstrument ] = Nil ,
33
+ dataProcessing : Seq [DataProcessing ] = Nil ,
35
34
// separation: Option[mzxml.Separation] = None,
36
35
// spotting: Option[mzxml.Spotting] = None,
37
36
scan : Seq [mzxml.ScanOrigin ] = Nil ,
@@ -43,9 +42,9 @@ object MsRun {
43
42
attribute[String ](" scanCount" ).map(_.toInt).optional,
44
43
attribute[String ](" startTime" ).map(DatatypeFactory .newInstance().newDuration).map(_.getSeconds).optional,
45
44
attribute[String ](" endTime" ).map(DatatypeFactory .newInstance().newDuration).map(_.getSeconds).optional,
46
- (__ \ " parentFile" ).read(seq[mzxml. ParentFile ]),
47
- (__ \ " msInstrument" )read(seq[mzxml. MsInstrument ]),
48
- (__ \ " dataProcessing" )read(seq[mzxml. DataProcessing ]),
45
+ (__ \ " parentFile" ).read(seq[ParentFile ]),
46
+ (__ \ " msInstrument" )read(seq[MsInstrument ]),
47
+ (__ \ " dataProcessing" )read(seq[DataProcessing ]),
49
48
(__ \ " scan" )read(seq[mzxml.ScanOrigin ]),
50
49
attribute[String ](" sha1" ).optional
51
50
).mapN(apply)
@@ -118,31 +117,31 @@ object MsInstrumentSequence {
118
117
}
119
118
120
119
case class MsInstrument (
121
- msInstrumentID : Option [String ],
122
- msManufacturer : mzxml. OntologyEntryTypable ,
123
- msModel : mzxml. OntologyEntryTypable ,
124
- msIonisation : mzxml. OntologyEntryTypable ,
125
- msMassAnalyzer : mzxml. OntologyEntryTypable ,
126
- msDetector : mzxml. OntologyEntryTypable ,
127
- software : mzxml. Software ,
128
- msResolution : Option [mzxml. OntologyEntryTypable ] = None ,
129
- operator : Option [mzxml. Operator ] = None ,
130
- msinstrumentsequence1 : Seq [mzxml. MsInstrumentSequence ] = Nil )
120
+ msInstrumentID : Option [String ],
121
+ msManufacturer : OntologyEntryTypable ,
122
+ msModel : OntologyEntryTypable ,
123
+ msIonisation : OntologyEntryTypable ,
124
+ msMassAnalyzer : OntologyEntryTypable ,
125
+ msDetector : OntologyEntryTypable ,
126
+ software : Software ,
127
+ msResolution : Option [OntologyEntryTypable ] = None ,
128
+ operator : Option [Operator ] = None ,
129
+ msinstrumentsequence1 : Seq [MsInstrumentSequence ] = Nil )
131
130
132
131
object MsInstrument {
133
132
134
133
implicit val reader : XmlReader [MsInstrument ] = {
135
134
(
136
135
attribute[String ](" msInstrumentID" ).optional,
137
- (__ \ " msManufacturer" ).read[mzxml. OntologyEntryTypable ],
138
- (__ \ " msModel" ).read[mzxml. OntologyEntryTypable ],
139
- (__ \ " msIonisation" ).read[mzxml. OntologyEntryTypable ],
140
- (__ \ " msMassAnalyzer" ).read[mzxml. OntologyEntryTypable ],
141
- (__ \ " msDetector" ).read[mzxml. OntologyEntryTypable ],
136
+ (__ \ " msManufacturer" ).read[OntologyEntryTypable ],
137
+ (__ \ " msModel" ).read[OntologyEntryTypable ],
138
+ (__ \ " msIonisation" ).read[OntologyEntryTypable ],
139
+ (__ \ " msMassAnalyzer" ).read[OntologyEntryTypable ],
140
+ (__ \ " msDetector" ).read[OntologyEntryTypable ],
142
141
(__ \ " software" ).read[Software ],
143
- (__ \ " msResolution" ).read[mzxml. OntologyEntryTypable ].optional,
144
- (__ \ " operator" ).read[mzxml. Operator ].optional,
145
- (__ \ " msinstrumentsequence" ).read(seq[mzxml. MsInstrumentSequence ])
142
+ (__ \ " msResolution" ).read[OntologyEntryTypable ].optional,
143
+ (__ \ " operator" ).read[Operator ].optional,
144
+ (__ \ " msinstrumentsequence" ).read(seq[MsInstrumentSequence ])
146
145
).mapN(apply)
147
146
}
148
147
}
@@ -154,8 +153,8 @@ case class DataProcessing(
154
153
deisotoped : Option [Boolean ],
155
154
chargeDeconvoluted : Option [Boolean ],
156
155
spotIntegration : Option [Boolean ],
157
- software : mzxml. Software ,
158
- dataprocessingsequence1 : Seq [mzxml. DataProcessingSequence ] = Nil
156
+ software : Software ,
157
+ dataprocessingsequence1 : Seq [DataProcessingSequence ] = Nil
159
158
)
160
159
object DataProcessing {
161
160
implicit val reader : XmlReader [DataProcessing ] = (
@@ -327,12 +326,12 @@ object Peaks {
327
326
mzs.zipWithIndex.map( x => (x._1,intensities(x._2))).filter(_._2> 0 ) // removes intensities equal to zero
328
327
}
329
328
330
- private def strToPrecision (name : String ): Value =
329
+ private def strToPrecision (name : String ): Precision . Value =
331
330
mzxml.Precision .values.find(_.toString.toLowerCase() == name.toLowerCase()).getOrElse(Precision .Number32 )
332
331
333
332
private val mzsIntensitiesPairReader : XmlReader [Seq [(Double ,Double )]] = {
334
333
for {
335
- base64 <- (__) .read[String ]
334
+ base64 <- __ .read[String ]
336
335
precision <- attribute[String ](" precision" )
337
336
compression <- attribute(" compressionType" )(enum (CompressionType )).default(CompressionType .NoneType )
338
337
} yield {
@@ -414,8 +413,8 @@ object ScanProperties {
414
413
415
414
case class ScanOrigin (
416
415
properties : mzxml.ScanProperties ,
417
- precursorMz : Seq [mzxml. PrecursorMz ] = Nil ,
418
- maldi : Option [mzxml. Maldi ] = None ,
416
+ precursorMz : Seq [PrecursorMz ] = Nil ,
417
+ maldi : Option [Maldi ] = None ,
419
418
peaks : Seq [mzxml.Peaks ] = Nil ,
420
419
scanSequence : Seq [mzxml.ScanSequence ] = Nil ,
421
420
scan : Seq [mzxml.SubScan ] = Nil
@@ -424,8 +423,8 @@ case class ScanOrigin(
424
423
object ScanOrigin {
425
424
implicit val reader : XmlReader [ScanOrigin ] = {
426
425
(__.read[ScanProperties ],
427
- ( __ \ " precursorMz" ).read(seq[mzxml. PrecursorMz ]),
428
- ( __ \ " maldi" ).read[mzxml. Maldi ].optional,
426
+ ( __ \ " precursorMz" ).read(seq[PrecursorMz ]),
427
+ ( __ \ " maldi" ).read[Maldi ].optional,
429
428
( __ \ " peaks" ).read(seq[mzxml.Peaks ]),
430
429
( __ \ " scanSequence" ).read(seq[mzxml.ScanSequence ]),
431
430
( __ \ " scan" ).read(seq[mzxml.SubScan ])
@@ -434,12 +433,12 @@ object ScanOrigin {
434
433
}
435
434
436
435
case class SubScan (
437
- properties : mzxml.ScanProperties ,
438
- precursorMz : Seq [mzxml. PrecursorMz ] = Nil ,
439
- maldi : Option [mzxml. Maldi ] = None ,
440
- peaks : Seq [mzxml.Peaks ] = Nil ,
441
- scansequence : Seq [mzxml.ScanSequence ] = Nil ,
442
- scan : Seq [mzxml.ScanOrigin ] = Nil
436
+ properties : mzxml.ScanProperties ,
437
+ precursorMz : Seq [PrecursorMz ] = Nil ,
438
+ maldi : Option [Maldi ] = None ,
439
+ peaks : Seq [mzxml.Peaks ] = Nil ,
440
+ scansequence : Seq [mzxml.ScanSequence ] = Nil ,
441
+ scan : Seq [mzxml.ScanOrigin ] = Nil
443
442
)
444
443
445
444
object SubScan {
0 commit comments