Skip to content

Commit

Permalink
Merge pull request #15 from p2m2/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ofilangi authored May 5, 2023
2 parents 06d9be4 + 67b09d4 commit 2d78af2
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 13 deletions.
22 changes: 19 additions & 3 deletions app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.{GenericP2M2, MassSpectrometryResultSet, MassSpectrometryResultSetFactory}
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
Expand Down Expand Up @@ -62,7 +63,7 @@ class HomeController @Inject()(
val information = s"($filename,$fileSize,$contentType)" +
"<br/>\\n \n nGCMSParser:"+GCMSParser.sniffFile(s"/tmp/$filename") +
"<br/>OpenLabCDSParser:"+OpenLabCDSParser.sniffFile(s"/tmp/$filename") +
"<br/>QuantifyCompoundSummaryReportMassLynxParser:"+QuantifyCompoundSummaryReportMassLynxParser.sniffFile(s"/tmp/$filename") +
"<br/>QuantifyCompoundSummaryReportMassLynxParser:"+QuantifySummaryReportMassLynxParser.sniffFile(s"/tmp/$filename") +
"<br/>XcaliburXlsParser:"+XcaliburXlsParser.sniffFile(s"/tmp/$filename")

val ms : Option[MassSpectrometryResultSet] = ParserManager.buildMassSpectrometryObject(s"/tmp/$filename")
Expand Down Expand Up @@ -125,4 +126,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]")
}
}

}
13 changes: 9 additions & 4 deletions app/daos/MassSpectrometryFileDAO.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,10 +19,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 {
Expand Down
2 changes: 1 addition & 1 deletion app/views/importMassSpectrometryFile.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@for(msFile <- listMSFiles ) {
<tr>
<td>@msFile.id</td>
<td>@msFile.name</td>
<td><a href="/preview_file/@msFile.id">@msFile.name</a></td>
<td>@msFile.className</td>
<td><a href="/delete/@msFile.id"><span class="material-symbols-outlined">delete</span></a></td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions app/views/preview.scala.html
Original file line number Diff line number Diff line change
@@ -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)") {
<table>
Expand All @@ -10,7 +10,7 @@
</tr>
</thead>
<tbody>
@for(values <- obj.values) {
@for(values <- obj.samples) {
<tr>
@for(header <- GenericP2M2.HeaderField.values.toSeq) {
<td>@values.get(header)</td>
Expand Down
38 changes: 38 additions & 0 deletions app/views/preview_GCMS.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@**************************************
* GCMS preview page. *
* *
* @ob The GCMS information to display *
**************************************@

@import fr.inrae.metabolomics.p2m2.format.ms._
@import fr.inrae.metabolomics.p2m2.parser.ParserUtils

@(obj : GCMS)
@main("GCMS preview") {
<h2>Header</h2>
<table>
@for(header <- GCMS.HeaderFileField.values.toSeq) {
<tr>
<td><b>@ParserUtils.toString(header)</b></td>
<td>@obj.header.get(header)</td>
</tr>
}
</table>

<h2>Results</h2>

<table>
<tr>
@for(header <- GCMS.HeaderField.values.toSeq) {
<td><b>@ParserUtils.toString(header)</b></td>
}
</tr>
@for(entry <- obj.msQuantitativeResults) {
<tr>
@for(header <- GCMS.HeaderField.values.toSeq) {
<td>@entry.get(header)</td>
}
</tr>
}
</table>
}
38 changes: 38 additions & 0 deletions app/views/preview_OpenLabCDS.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@********************************************
* OpenLabCDS preview page. *
* *
* @ob The OpenLabCDS information to display *
*********************************************@

@import fr.inrae.metabolomics.p2m2.format.ms._
@import fr.inrae.metabolomics.p2m2.parser.ParserUtils

@(obj : OpenLabCDS)
@main("OpenLabCDS preview") {
<h2>Header</h2>
<table>
@for(header <- OpenLabCDS.HeaderFileField.values.toSeq) {
<tr>
<td><b>@ParserUtils.toString(header)</b></td>
<td>@obj.header.get(header)</td>
</tr>
}
</table>

<h2>Results</h2>

<table>
<tr>
@for(header <- OpenLabCDS.HeaderField.values.toSeq) {
<td><b>@ParserUtils.toString(header)</b></td>
}
</tr>
@for(entry <- obj.results) {
<tr>
@for(header <- OpenLabCDS.HeaderField.values.toSeq) {
<td>@entry.get(header)</td>
}
</tr>
}
</table>
}
41 changes: 41 additions & 0 deletions app/views/preview_QuantifyCompoundSummaryReportMassLynx.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@***********************************************************************
* QuantifyCompoundSummaryReportMassLynx preview page. *
* *
* @ob The QuantifyCompoundSummaryReportMassLynx information to display *
************************************************************************@

@import fr.inrae.metabolomics.p2m2.format.ms._
@import fr.inrae.metabolomics.p2m2.parser.ParserUtils

@(obj : QuantifyCompoundSummaryReportMassLynx)
@main("QuantifyCompoundSummaryReportMassLynx preview") {
<h2>Header</h2>
<table>
<tr>
<td><b>Printed Date</b></td>
<td>@obj.header.dateStr</td>
</tr>

</table>

<h2>Results</h2>
<table>
<tr>
<td> - </td>
@for(header <- QuantifyCompoundSummaryReportMassLynx.HeaderField.values.toSeq) {
<td><b>@ParserUtils.toString(header)</b></td>
}
</tr>
@for(entry <- obj.resultsByCompound) {
@for(values <- entry._2) {
<tr>
<td>@entry._1</td>
@for(header <- QuantifyCompoundSummaryReportMassLynx.HeaderField.values.toSeq) {
<td>@values.get(header)</td>
}
</tr>
}
}
</table>

}
46 changes: 46 additions & 0 deletions app/views/preview_Xcalibur.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@********************************************
* Xcalibur preview page. *
* *
* @ob The Xcalibur information to display *
*********************************************@

@import fr.inrae.metabolomics.p2m2.format.ms._
@import fr.inrae.metabolomics.p2m2.parser.ParserUtils

@(obj : Xcalibur)
@main("Xcalibur preview") {
<h2>Sheets</h2>

@for(sheet <- obj.results) {
<h3>Header</h3>
<table>
@for(header <- Xcalibur.HeaderSheetField.values.toSeq) {
<tr>
<td><b>@ParserUtils.toString(header)</b></td>
<td>@sheet.compoundInformationHeader.get(header)</td>
</tr>
}
</table>

<h3>Results</h3>
<table>
<tr>
@for(header <- Xcalibur.HeaderField.values.toSeq) {
<td><b>@ParserUtils.toString(header)</b></td>
}
</tr>
@for(values <- sheet.compoundByInjection) {
<tr>
@for(header <- Xcalibur.HeaderField.values.toSeq) {
<td>@values.get(header)</td>
}
</tr>
}
</table>

}




}
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions conf/routes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d78af2

Please sign in to comment.