From 282c21e4d4a6acf89d83dfd7d104fceb610aa33d Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 2 Sep 2022 14:01:25 +0200 Subject: [PATCH 1/4] add preview for xcalibur, gcms, openlabcds, masslynx --- app/controllers/HomeController.scala | 17 ++++++- app/daos/MassSpectrometryFileDAO.scala | 10 ++-- .../importMassSpectrometryFile.scala.html | 2 +- app/views/preview_GCMS.scala.html | 38 +++++++++++++++ app/views/preview_OpenLabCDS.scala.html | 38 +++++++++++++++ ...fyCompoundSummaryReportMassLynx.scala.html | 41 +++++++++++++++++ app/views/preview_Xcalibur.scala.html | 46 +++++++++++++++++++ conf/routes | 1 + 8 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 app/views/preview_GCMS.scala.html create mode 100644 app/views/preview_OpenLabCDS.scala.html create mode 100644 app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html create mode 100644 app/views/preview_Xcalibur.scala.html diff --git a/app/controllers/HomeController.scala b/app/controllers/HomeController.scala index 71b363e..5bdb294 100644 --- a/app/controllers/HomeController.scala +++ b/app/controllers/HomeController.scala @@ -3,7 +3,7 @@ package controllers import akka.stream.scaladsl.{Source, StreamConverters} import akka.util.ByteString import daos.MassSpectrometryFileDAO -import fr.inrae.metabolomics.p2m2.format.{GenericP2M2, MassSpectrometryResultSet, MassSpectrometryResultSetFactory} +import fr.inrae.metabolomics.p2m2.format.{GCMS, GenericP2M2, MassSpectrometryResultSet, MassSpectrometryResultSetFactory, OpenLabCDS, QuantifyCompoundSummaryReportMassLynx, Xcalibur} import fr.inrae.metabolomics.p2m2.parser._ import fr.inrae.metabolomics.p2m2.stream.ExportData import models.MassSpectrometryFile @@ -125,4 +125,19 @@ class HomeController @Inject()( } } + def preview_file(idMsFile : Long) : Action[AnyContent] = Action.async { + msfiles.findById(idMsFile) map { + case Some(s) => MassSpectrometryResultSetFactory.build(s.fileContent) match { + case Some (obj: GCMS) => Ok (views.html.preview_GCMS (obj) ) + case Some (obj: OpenLabCDS) => Ok (views.html.preview_OpenLabCDS(obj) ) + case Some (obj: QuantifyCompoundSummaryReportMassLynx) => + Ok (views.html.preview_QuantifyCompoundSummaryReportMassLynx(obj) ) + case Some (obj: Xcalibur) => Ok (views.html.preview_Xcalibur(obj) ) + case None => Ok (s"can not convert string to type [${s.fileContent}]") + case _ => Ok (s"can not preview file [id:$idMsFile]") + } + case None => Ok (s"Can not find Id file [id:$idMsFile]") + } + } + } diff --git a/app/daos/MassSpectrometryFileDAO.scala b/app/daos/MassSpectrometryFileDAO.scala index bd2412d..2abd4b6 100644 --- a/app/daos/MassSpectrometryFileDAO.scala +++ b/app/daos/MassSpectrometryFileDAO.scala @@ -18,10 +18,14 @@ class MassSpectrometryFileDAO @Inject() import profile.api._ - def findAll(): Seq[MassSpectrometryFile] = ??? - def findById(id: String) : MassSpectrometryFile = ??? + def findById(id: Long) : Future[Option[MassSpectrometryFile]] = + db.run(TableQuery[MassSpectrometryFileTable].filter(_.id === id).result).map { + case l if l.nonEmpty => Some(l.last) + case _ => None + } - def all(): Future[Seq[MassSpectrometryFile]] = db.run(TableQuery[MassSpectrometryFileTable].result) + def all(): Future[Seq[MassSpectrometryFile]] = + db.run(TableQuery[MassSpectrometryFileTable].result) def getMergeGenericP2M2() : Future[GenericP2M2] = { all().map { diff --git a/app/views/importMassSpectrometryFile.scala.html b/app/views/importMassSpectrometryFile.scala.html index 419e37e..e8fd127 100644 --- a/app/views/importMassSpectrometryFile.scala.html +++ b/app/views/importMassSpectrometryFile.scala.html @@ -17,7 +17,7 @@ @for(msFile <- listMSFiles ) { @msFile.id - @msFile.name + @msFile.name @msFile.className delete diff --git a/app/views/preview_GCMS.scala.html b/app/views/preview_GCMS.scala.html new file mode 100644 index 0000000..b6f3001 --- /dev/null +++ b/app/views/preview_GCMS.scala.html @@ -0,0 +1,38 @@ +@************************************** +* GCMS preview page. * +* * +* @ob The GCMS information to display * +**************************************@ + +@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.parser.ParserUtils + +@(obj : GCMS) +@main("GCMS preview") { +

Header

+ + @for(header <- GCMS.HeaderFileField.values.toSeq) { + + + + + } +
@ParserUtils.toString(header)@obj.header.get(header)
+ +

Results

+ + + + @for(header <- GCMS.HeaderField.values.toSeq) { + + } + + @for(entry <- obj.msQuantitativeResults) { + + @for(header <- GCMS.HeaderField.values.toSeq) { + + } + + } +
@ParserUtils.toString(header)
@entry.get(header)
+} \ No newline at end of file diff --git a/app/views/preview_OpenLabCDS.scala.html b/app/views/preview_OpenLabCDS.scala.html new file mode 100644 index 0000000..589e46d --- /dev/null +++ b/app/views/preview_OpenLabCDS.scala.html @@ -0,0 +1,38 @@ +@******************************************** +* OpenLabCDS preview page. * +* * +* @ob The OpenLabCDS information to display * +*********************************************@ + +@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.parser.ParserUtils + +@(obj : OpenLabCDS) +@main("OpenLabCDS preview") { +

Header

+ + @for(header <- OpenLabCDS.HeaderFileField.values.toSeq) { + + + + + } +
@ParserUtils.toString(header)@obj.header.get(header)
+ +

Results

+ + + + @for(header <- OpenLabCDS.HeaderField.values.toSeq) { + + } + + @for(entry <- obj.results) { + + @for(header <- OpenLabCDS.HeaderField.values.toSeq) { + + } + + } +
@ParserUtils.toString(header)
@entry.get(header)
+} \ No newline at end of file diff --git a/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html b/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html new file mode 100644 index 0000000..6e07fdb --- /dev/null +++ b/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html @@ -0,0 +1,41 @@ +@*********************************************************************** +* QuantifyCompoundSummaryReportMassLynx preview page. * +* * +* @ob The QuantifyCompoundSummaryReportMassLynx information to display * +************************************************************************@ + +@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.parser.ParserUtils + +@(obj : QuantifyCompoundSummaryReportMassLynx) +@main("QuantifyCompoundSummaryReportMassLynx preview") { +

Header

+ + + + + + +
Printed Date@obj.header.dateStr
+ +

Results

+ + + + @for(header <- QuantifyCompoundSummaryReportMassLynx.HeaderField.values.toSeq) { + + } + + @for(entry <- obj.results) { + @for(values <- entry._2) { + + + @for(header <- QuantifyCompoundSummaryReportMassLynx.HeaderField.values.toSeq) { + + } + + } + } +
- @ParserUtils.toString(header)
@entry._1@values.get(header)
+ +} \ No newline at end of file diff --git a/app/views/preview_Xcalibur.scala.html b/app/views/preview_Xcalibur.scala.html new file mode 100644 index 0000000..c322609 --- /dev/null +++ b/app/views/preview_Xcalibur.scala.html @@ -0,0 +1,46 @@ +@******************************************** +* Xcalibur preview page. * +* * +* @ob The Xcalibur information to display * +*********************************************@ + +@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.parser.ParserUtils + +@(obj : Xcalibur) +@main("Xcalibur preview") { +

Sheets

+ + @for(sheet <- obj.results) { +

Header

+ + @for(header <- Xcalibur.HeaderSheetField.values.toSeq) { + + + + + } +
@ParserUtils.toString(header)@sheet.compoundInformationHeader.get(header)
+ +

Results

+ + + @for(header <- Xcalibur.HeaderField.values.toSeq) { + + } + + @for(values <- sheet.compoundByInjection) { + + @for(header <- Xcalibur.HeaderField.values.toSeq) { + + } + + } +
@ParserUtils.toString(header)
@values.get(header)
+ + } + + + + +} \ No newline at end of file diff --git a/conf/routes b/conf/routes index aa322a4..4dc3a61 100644 --- a/conf/routes +++ b/conf/routes @@ -11,6 +11,7 @@ GET /importMSF controllers.HomeController.importMassSpectrom POST /upload controllers.HomeController.upload() GET /delete/:idMsFileLong controllers.HomeController.delete(idMsFileLong : Long) GET /preview controllers.HomeController.preview() +GET /preview_file/:idMsFileLong controllers.HomeController.preview_file(idMsFileLong : Long) GET /clean controllers.HomeController.clean() GET /exportXLS controllers.HomeController.exportXLS() # Map static resources from the /public folder to the /assets URL path From 6ebb21f6f7e88886f96190b31176032bd9731ad9 Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Thu, 8 Sep 2022 15:31:33 +0200 Subject: [PATCH 2/4] update preview html --- app/views/preview.scala.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/preview.scala.html b/app/views/preview.scala.html index 9e5957a..827092d 100644 --- a/app/views/preview.scala.html +++ b/app/views/preview.scala.html @@ -10,7 +10,7 @@ - @for(values <- obj.values) { + @for(values <- obj.samples) { @for(header <- GenericP2M2.HeaderField.values.toSeq) { @values.get(header) From 0c91b3480fa6525a5d879b6cb75c08486dc96beb Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Tue, 13 Sep 2022 16:57:29 +0200 Subject: [PATCH 3/4] fix new p2m2tool jar dependancies --- app/controllers/HomeController.scala | 7 ++++--- app/daos/MassSpectrometryFileDAO.scala | 3 ++- app/views/preview.scala.html | 2 +- app/views/preview_GCMS.scala.html | 2 +- app/views/preview_OpenLabCDS.scala.html | 2 +- ...review_QuantifyCompoundSummaryReportMassLynx.scala.html | 4 ++-- app/views/preview_Xcalibur.scala.html | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/controllers/HomeController.scala b/app/controllers/HomeController.scala index 5bdb294..4f41082 100644 --- a/app/controllers/HomeController.scala +++ b/app/controllers/HomeController.scala @@ -3,8 +3,9 @@ package controllers import akka.stream.scaladsl.{Source, StreamConverters} import akka.util.ByteString import daos.MassSpectrometryFileDAO -import fr.inrae.metabolomics.p2m2.format.{GCMS, GenericP2M2, MassSpectrometryResultSet, MassSpectrometryResultSetFactory, OpenLabCDS, QuantifyCompoundSummaryReportMassLynx, Xcalibur} -import fr.inrae.metabolomics.p2m2.parser._ +import fr.inrae.metabolomics.p2m2.format.MassSpectrometryResultSetFactory +import fr.inrae.metabolomics.p2m2.format.ms.{GCMS, GenericP2M2, MassSpectrometryResultSet, OpenLabCDS, QuantifyCompoundSummaryReportMassLynx, QuantifySampleSummaryReportMassLynx, Xcalibur} +import fr.inrae.metabolomics.p2m2.parser.{GCMSParser, OpenLabCDSParser, ParserManager, QuantifySummaryReportMassLynxParser, XcaliburXlsParser} import fr.inrae.metabolomics.p2m2.stream.ExportData import models.MassSpectrometryFile import play.api.http.HttpEntity @@ -62,7 +63,7 @@ class HomeController @Inject()( val information = s"($filename,$fileSize,$contentType)" + "
\\n \n nGCMSParser:"+GCMSParser.sniffFile(s"/tmp/$filename") + "
OpenLabCDSParser:"+OpenLabCDSParser.sniffFile(s"/tmp/$filename") + - "
QuantifyCompoundSummaryReportMassLynxParser:"+QuantifyCompoundSummaryReportMassLynxParser.sniffFile(s"/tmp/$filename") + + "
QuantifyCompoundSummaryReportMassLynxParser:"+QuantifySummaryReportMassLynxParser.sniffFile(s"/tmp/$filename") + "
XcaliburXlsParser:"+XcaliburXlsParser.sniffFile(s"/tmp/$filename") val ms : Option[MassSpectrometryResultSet] = ParserManager.buildMassSpectrometryObject(s"/tmp/$filename") diff --git a/app/daos/MassSpectrometryFileDAO.scala b/app/daos/MassSpectrometryFileDAO.scala index 2abd4b6..e7dfc86 100644 --- a/app/daos/MassSpectrometryFileDAO.scala +++ b/app/daos/MassSpectrometryFileDAO.scala @@ -1,6 +1,7 @@ package daos -import fr.inrae.metabolomics.p2m2.format.{GenericP2M2, MassSpectrometryResultSetFactory} +import fr.inrae.metabolomics.p2m2.format.MassSpectrometryResultSetFactory +import fr.inrae.metabolomics.p2m2.format.ms.GenericP2M2 import scala.concurrent.{ExecutionContext, Future} import javax.inject.Inject diff --git a/app/views/preview.scala.html b/app/views/preview.scala.html index 827092d..8b7d031 100644 --- a/app/views/preview.scala.html +++ b/app/views/preview.scala.html @@ -1,4 +1,4 @@ -@import fr.inrae.metabolomics.p2m2.format.GenericP2M2 +@import fr.inrae.metabolomics.p2m2.format.ms.GenericP2M2 @(obj : GenericP2M2) @main("Merge all results file (preview)") { diff --git a/app/views/preview_GCMS.scala.html b/app/views/preview_GCMS.scala.html index b6f3001..c4ae28e 100644 --- a/app/views/preview_GCMS.scala.html +++ b/app/views/preview_GCMS.scala.html @@ -4,7 +4,7 @@ * @ob The GCMS information to display * **************************************@ -@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.format.ms._ @import fr.inrae.metabolomics.p2m2.parser.ParserUtils @(obj : GCMS) diff --git a/app/views/preview_OpenLabCDS.scala.html b/app/views/preview_OpenLabCDS.scala.html index 589e46d..8d19766 100644 --- a/app/views/preview_OpenLabCDS.scala.html +++ b/app/views/preview_OpenLabCDS.scala.html @@ -4,7 +4,7 @@ * @ob The OpenLabCDS information to display * *********************************************@ -@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.format.ms._ @import fr.inrae.metabolomics.p2m2.parser.ParserUtils @(obj : OpenLabCDS) diff --git a/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html b/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html index 6e07fdb..42012f5 100644 --- a/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html +++ b/app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html @@ -4,7 +4,7 @@ * @ob The QuantifyCompoundSummaryReportMassLynx information to display * ************************************************************************@ -@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.format.ms._ @import fr.inrae.metabolomics.p2m2.parser.ParserUtils @(obj : QuantifyCompoundSummaryReportMassLynx) @@ -26,7 +26,7 @@

Results

} - @for(entry <- obj.results) { + @for(entry <- obj.resultsByCompound) { @for(values <- entry._2) { diff --git a/app/views/preview_Xcalibur.scala.html b/app/views/preview_Xcalibur.scala.html index c322609..9319f40 100644 --- a/app/views/preview_Xcalibur.scala.html +++ b/app/views/preview_Xcalibur.scala.html @@ -4,7 +4,7 @@ * @ob The Xcalibur information to display * *********************************************@ -@import fr.inrae.metabolomics.p2m2.format._ +@import fr.inrae.metabolomics.p2m2.format.ms._ @import fr.inrae.metabolomics.p2m2.parser.ParserUtils @(obj : Xcalibur) From 67b09d459151b5eee3797aafb289b679e4509bae Mon Sep 17 00:00:00 2001 From: Olivier Filangi Date: Fri, 5 May 2023 15:17:15 +0200 Subject: [PATCH 4/4] update p2m2tools lib --- build.sbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index 494c77a..ea7247c 100644 --- a/build.sbt +++ b/build.sbt @@ -9,9 +9,9 @@ scalaVersion := "2.13.8" libraryDependencies ++= Seq( guice, - "com.github.p2m2" %% "p2m2tools" % "develop-SNAPSHOT" changing(), - "com.typesafe.play" %% "play-slick" % "5.0.2", - "com.typesafe.play" %% "play-slick-evolutions" % "5.0.2", + "com.github.p2m2" %% "p2m2tools" % "0.2.0" changing(), + "com.typesafe.play" %% "play-slick" % "5.1.0", + "com.typesafe.play" %% "play-slick-evolutions" % "5.1.0", "com.h2database" % "h2" % "2.1.214", "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test )
@ParserUtils.toString(header)
@entry._1