Skip to content

Commit d487f42

Browse files
committed
first commit
0 parents  commit d487f42

File tree

11 files changed

+2713
-0
lines changed

11 files changed

+2713
-0
lines changed

Readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

build.sbt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
// The simplest possible sbt build file is just one line:
3+
4+
scalaVersion := "2.13.8"
5+
// That is, to create a valid sbt build, all you've got to do is define the
6+
// version of Scala you'd like your project to use.
7+
8+
// ============================================================================
9+
10+
// Lines like the above defining `scalaVersion` are called "settings". Settings
11+
// are key/value pairs. In the case of `scalaVersion`, the key is "scalaVersion"
12+
// and the value is "2.13.8"
13+
14+
// It's possible to define many kinds of settings, such as:
15+
16+
name := "mzXML-stream"
17+
organization := "com.github.p2m2"
18+
version := "1.0"
19+
20+
21+
libraryDependencies ++= Seq(
22+
"org.scalaxb" %% "scalaxb" % "1.11.1",
23+
"org.scala-lang.modules" %% "scala-xml" % "2.1.0",
24+
"javax.xml.bind" % "jaxb-api" % "2.3.1",
25+
"co.fs2" %% "fs2-core" % "3.9.2",
26+
"co.fs2" %% "fs2-io" % "3.9.2",
27+
"co.fs2" %%"fs2-core"%"3.9.2",
28+
"org.gnieh" %%"fs2-data-xml"%"1.8.0"
29+
)
30+
31+
Global / onChangedBuildSource := ReloadOnSourceChanges

dev.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## scalaxb
2+
3+
- install scalaxb = https://github.com/eed3si9n/scalaxb/
4+
- generate class from XSD
5+
wget https://sashimi.sourceforge.net/schema_revision/mzXML_3.2/mzXML_3.2.xsd
6+
mkdir separations
7+
pushd separations
8+
wget http://sashimi.sourceforge.net/schema_revision/mzXML_3.2/separations/separation_technique_1.0.xsd
9+
popd
10+
wget http://sashimi.sourceforge.net/schema_revision/mzXML_3.2/general_types_1.0.xsd
11+
12+
scalaxb mzXML_3.2.xsd separations/separation_technique_1.0.xsd general_types_1.0.xsd -p mzxml

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.9.6

project/plugins.sbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
2+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.0")
3+
addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.1")
4+
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
5+

src/main/scala/Main.scala

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import cats.Show
2+
import fs2.Stream
3+
import cats.effect.{IO, IOApp}
4+
import cats.effect.unsafe.implicits.global
5+
import fs2._
6+
import fs2.data.xml
7+
import fs2.io.file.{Files, Flags, Path}
8+
import fs2.data.xml._
9+
import fs2.data.xml.xpath.{XPath, XPathParser}
10+
import fs2.data.xml.xpath.literals._
11+
import mzxml.ScanOrigin
12+
13+
import scala.xml.{NodeSeq, XML}
14+
15+
object Main extends IOApp.Simple {
16+
println("Hello, World!")
17+
val base= "/media/ofilangi/hdd-local/workspace/INRAE"
18+
val data1 = s"$base/P2M2/mzxml-glucosinolate-analyser/src/test/resources/test.mzXML"
19+
val data2 = s"$base/P2M2/mzxml-glucosinolate-analyser/src/test/resources/20181018-037.mzXML"
20+
val data3 = s"$base/P2M2/brachemdb-workflow/fragmentation/MetFrag/matchms_processing/Brassinet F 20 A 1500 uL 0.14 ug Api Neg_01_7768.mzXML"
21+
22+
def converter (path: XPath): Stream[IO, String] = {
23+
val stream: Stream[IO, Byte] = Files[IO].readAll(fs2.io.file.Path("test.mzXML"))
24+
//.through(text.utf8.decode)
25+
//.through(text.lines)
26+
// .through(events[IO, String]())
27+
IO{ println("Hello World !!!2") }
28+
29+
val streamTxt: Stream[IO, XmlEvent] = stream.through(text.utf8.decode).through(events[IO, String]())
30+
//val nsResolved = streamTxt.through(namespaceResolver[IO])
31+
//val entityResolved = nsResolved.through(referenceResolver[IO]())
32+
33+
34+
35+
streamTxt
36+
.through(xml.xpath.filter.raw(path))
37+
.parEvalMapUnbounded(_.map(Show[XmlEvent].show(_)).compile.foldMonoid)
38+
//.through(xml.xpath.filter.collect(path, scalaxb.fromXML[mzxml.Scan]))
39+
// .through(normalize)
40+
// .map( eventXml => scalaxb.fromXML[mzxml.Scan](XML.loadString(eventXml)) )
41+
42+
// eventXmlsIo.map( eventXmls => eventXmls.map( e => scalaxb.fromXML[mzxml.Scan](XML.loadString(e))) )
43+
}
44+
45+
val msRun: Stream[IO, mzxml.MsRun] =
46+
converter(xpath"//msRun")
47+
.map(eventXml => scalaxb.fromXML[mzxml.MsRun](XML.loadString(eventXml)))
48+
49+
val msInstrument: Stream[IO, mzxml.MsInstrument] =
50+
converter(xpath"//msInstrument")
51+
.map(eventXml => { println(eventXml);scalaxb.fromXML[mzxml.MsInstrument](XML.loadString(eventXml)) })
52+
53+
val dataProcessing: Stream[IO, mzxml.DataProcessing] =
54+
converter(xpath"/mzXML/msRun/dataProcessing")
55+
.map(eventXml => scalaxb.fromXML[mzxml.DataProcessing](XML.loadString(eventXml)))
56+
57+
val scans : Stream[IO, mzxml.ScanOrigin] =
58+
converter(xpath"//scan")
59+
.map( eventXml => scalaxb.fromXML[mzxml.ScanOrigin](XML.loadString(eventXml)) )
60+
61+
62+
63+
def run: IO[Unit] =
64+
{
65+
IO {
66+
println(
67+
scans
68+
.filter(x => x.num == 10)
69+
.compile
70+
.toList
71+
.unsafeRunSync())
72+
}
73+
//scans.compile.drain
74+
}
75+
76+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Generated by <a href="http://scalaxb.org/">scalaxb</a>.
2+
package mzxml
3+
4+
5+
case class NamevalueType(value: scalaxb.DataRecord[Any],
6+
attributes: Map[String, scalaxb.DataRecord[Any]] = Map.empty) {
7+
lazy val name = attributes.get("@name") map { _.as[String]}
8+
lazy val valueAttribute = attributes.get("@value") map { _.as[scalaxb.DataRecord[Any]]}
9+
lazy val typeValue = attributes.get("@type") map { _.as[scalaxb.DataRecord[Any]]}
10+
}
11+
12+
13+
14+
15+
16+
trait OntologyEntryTypable {
17+
def category: String
18+
def valueAttribute: String
19+
}
20+
21+
22+
case class OntologyEntryType(attributes: Map[String, scalaxb.DataRecord[Any]] = Map.empty) extends OntologyEntryTypable {
23+
lazy val category = attributes("@category").as[String]
24+
lazy val valueAttribute = attributes("@value").as[String]
25+
}
26+
27+
28+
29+

0 commit comments

Comments
 (0)