Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • eci/shinyscreen
  • miroslav.kratochvil/shinyscreen
2 results
Show changes
Showing
with 391 additions and 130 deletions
......@@ -175,10 +175,11 @@ mv PubChemLite_exposomics_20230127.csv /usr/local/metfrag_db/PubChemLite_exposom
** Terminology
- Project directory :: This is directory containing Shinyscreen inputs
(except the ~mzML~ files), intermediate and output files. The inputs
are /compound/ and /set/ lists (information on the list inputs is
available from Shinyscreen GUI application itself).
- Project directory :: This is directory containing the compound list,
intermediate and output files. At the beginning, it contains only
the compound list.
- Compound list :: A CSV which lists the masses that should be
extracted and various metadata.
- Data directory :: A data directory contains ~mzML~ files.
- Projects directory :: A directory containing the Shinyscreen
~project~ directories.
......
......@@ -22,16 +22,16 @@ RUN rm -rf /var/lib/apt/lists/*
RUN rm -rf /tmp/*
# Add MetFrag.
RUN curl -LJO https://gitlab.lcsb.uni.lu/eci/shinyscreen_needs/-/raw/master/MetFragCommandLine-2.5.0.jar
RUN curl -LJO https://gitlab.com/uniluxembourg/lcsb/eci/shinyscreen/raw/test/docker/metfrag/MetFragCommandLine-2.6.1.jar
# RUN curl -LJO https://github.com/ipb-halle/MetFragRelaunched/releases/download/v.2.5.0/MetFragCommandLine-2.5.0.jar
RUN mv MetFragCommandLine-2.5.0.jar /usr/local/bin/MetFragCommandLine.jar
RUN mv MetFragCommandLine-2.6.1.jar /usr/local/bin/MetFragCommandLine.jar
RUN chmod 0555 /usr/local/bin/MetFragCommandLine.jar
# Add PCL.
RUN curl -LJO https://zenodo.org/record/7576412/files/PubChemLite_exposomics_20230127.csv
RUN curl -LJO https://zenodo.org/records/14781118/files/PubChemLite_exposomics_20250131.csv
RUN mkdir /usr/local/metfrag_db
RUN chmod 0555 /usr/local/metfrag_db
RUN mv PubChemLite_exposomics_20230127.csv /usr/local/metfrag_db/PubChemLite_exposomics.csv
RUN mv PubChemLite_exposomics_20250131.csv /usr/local/metfrag_db/PubChemLite_exposomics.csv
RUN MAKEFILE=j R -e 'install.packages("enviPat", dependencies=TRUE)'
RUN MAKEFILE=j R -e 'BiocManager::install(c("Rhdf5lib","mzR","MSnbase","RMassBank"),update=F)'
......
......@@ -9,4 +9,4 @@ RUN curl -LJO https://zenodo.org/record/3666069/files/ISB401_WT_pos.mzML
WORKDIR /home/ssuser/
RUN curl -LJO https://gitlab.lcsb.uni.lu/eci/isb401/-/archive/master/isb401-master.tar.gz
RUN tar -xf isb401-master.tar.gz
RUN cp isb401-master/shinyscreen_files/*.csv /home/ssuser/projects/isb401
\ No newline at end of file
RUN cp isb401-master/shinyscreen_files/*.csv /home/ssuser/projects/isb401
......@@ -194,7 +194,7 @@ overload of the system's resources.
```{r, echo=F}
## This is treated differently than other MF inputs, because the value
## is not known prior to starting a R session. There should be a
## mechanism for this. TODO FIXME.
## mechanism for this. TODO
numericInput(inputId="mf_proc",
label="Number of MetFrag processes",
......
......@@ -103,10 +103,10 @@ textOutput("curr_data_dir")
#### Select compound lists
<details><summary>About compound lists</summary>
A compound list is composed of entries describing compounds. This
description is used to search for its spectrum in the data file. The
list is a table in the ***CSV*** format and contains these columns,
<details><summary>About compound lists</summary> A compound list is
composed of entries describing compounds. This description is used to
search for its spectrum in the data file. The list is a table in the
***CSV*** format and contains some of these columns,
* ***ID*** : required column, must be filled; this is a user-defined
ID, uniquely associated with a compound
......@@ -115,30 +115,30 @@ list is a table in the ***CSV*** format and contains these columns,
names of the compounds
* ***SMILES*** : a _SMILES_ string, describing the structure of the
compound; this entry can be left empty only if one of either
***Formula***, or ***mz*** entries are not
compound
* ***Formula*** : a chemical formula of a compound; this field can be
empty only if one of either ***SMILES***, or ***mz*** entries are
not
* ***mz*** : mass of the ionised compound; this field can be left
empty only if one of either ***SMILES***, or ***Formula*** is not
* ***CAS*** : the CAS number of the compound; it can be left empty
* ***mz*** : mass of the ionised compound
* ***RT*** : retention time of the MS1 peak in minutes, if known; can
be left empty.
Only ***ID*** and one of ***SMILES***, ***Formula*** or ***mz*** must
be filled. When structure, or a formula of a compound is known, it is
also possible to look for various adducts in the sample. Of course,
scanning for completely unknown compounds is also supported by the
***mz*** column. In this case, ***mz*** is the mass of the ion.
* ***set*** : used to subset a compound list. For example, if the list
contains 100000 compounds and we only want to extract ten, those ten
rows should contain the same string in the ***set*** column. If the
***set** column is left out, all compounds are grouped into a single
set.
Only ***ID*** and one of ***SMILES*** or ***mz*** must be
present. When structure is known, it is also possible to look for
various adducts in the sample. Of course, scanning for completely
unknown compounds is also supported by the ***mz*** column. In this
case, ***mz*** is the mass of the ion.
It is strongly recommended to quote SMILES, names and formulas in the
CSV file used with Shinyscreen.
If the ***Name*** column exists, it will be shown in the plots.
Select one, or more compound lists by clicking `Select` button.
</details>
......
File added
File deleted
......@@ -11,7 +11,8 @@ empty_envopts(
metfrag_db_dir = NULL,
metfrag_jar = NULL,
java_bin = NULL,
metfrag_max_proc = NULL
metfrag_max_proc = NULL,
no_structure_plots = NULL
)
}
\arguments{
......@@ -37,6 +38,9 @@ has been supplied, we will try to detect it.}
\item{metfrag_max_proc}{\code{integer(1)}, maximum number of CPU cores
available for MetFrag. If no number has been supplied, we will
try to detect the number of logical CPUs and go with that.}
\item{no_structure_plots}{\code{logical(1)}, if T, structures will not
be plotted, even when it is possibile.}
}
\value{
An \code{envopts} object.
......
......@@ -12,6 +12,7 @@ init(
metfrag_jar = NULL,
java_bin = NULL,
metfrag_max_proc = NULL,
no_structure_plots = NULL,
merge = T,
save = F,
conf_dir = tools::R_user_dir(package = "shinyscreen", which = "config")
......@@ -41,6 +42,9 @@ has been supplied, we will try to detect it.}
available for MetFrag. If no number has been supplied, we will
try to detect the number of logical CPUs and go with that.}
\item{no_structure_plots}{\code{logical(1)}, if T, structures will not
be plotted, even when it is possibile.}
\item{merge}{\code{logical(1)}, optional. If T, merge with saved
configuration.}
......
File added
#!/bin/Rscript
nthreads = as.integer(Sys.getenv("SS_CPU"))
mf_db_dir = Sys.getenv("SS_MF_DB_DIR")
user = Sys.getenv("SS_USER")
# Load required libraries
library(future)
plan("sequential")
if (nthreads > 1L) plan("multisession",workers=nthreads)
library(shinyscreen)
carg = commandArgs(trailingOnly=T)
eo = init(metfrag_db_dir=mf_db_dir)
if (length(carg)>0L) {
if (carg[[1]]=="app") {
app(envopts=eo,shiny_args=list(launch.browser=F,port=3838))
} else if (carg[[1]]=="serve") {
app(envopts=eo,shiny_args=list(launch.browser=F,
port=3838L,
host="0.0.0.0"))
} else if (carg[[1]]=="test") {
# Set the number of threads
nthreads <- as.integer(Sys.getenv("SS_CPU"))
if (is.na(nthreads)) nthreads <- 1
cat("Number of threads:", nthreads, "\n")
# Set the plan based on the number of threads
plan("sequential")
if (nthreads > 1L) plan("multisession", workers=nthreads)
# Get environment variables
mf_db_dir <- Sys.getenv("SS_MF_DB_DIR")
if (mf_db_dir == "") mf_db_dir <- NULL
user <- Sys.getenv("SS_USER")
# Initialize environment options
eo <- init(metfrag_db_dir=mf_db_dir)
# Get command-line arguments
carg <- commandArgs(trailingOnly=TRUE)
cat("Command-line arguments:", carg, "\n")
# Check the command-line arguments and call the appropriate function
if (length(carg) > 0L) {
if (carg[[1]] == "app") {
cat("Starting app...\n")
app(envopts=eo, shiny_args=list(launch.browser=FALSE, port=3838, host="0.0.0.0"))
} else if (carg[[1]] == "serve") {
cat("Starting serve...\n")
app(envopts=eo, shiny_args=list(launch.browser=FALSE, port=3838L, host="0.0.0.0"))
} else if (carg[[1]] == "test") {
cat("Running tests...\n")
setwd("/home/ssuser/shinyscreen")
devtools::load_all()
devtools::test()
} else {
stop("Argument should be either `app', `test', or `serve'")
stop("Argument should be either 'app', 'test', or 'serve'")
}
} else {
app(envopts=eo,shiny_args=list(launch.browser=F,
port=3838L,
host="0.0.0.0"))
cat("No arguments provided, starting app by default...\n")
app(envopts=eo, shiny_args=list(launch.browser=FALSE, port=3838L, host="0.0.0.0"))
}
# uniqy_slugs
Code
out
Output
[1] "f1" "f2_1" "f2_2" "f2_3" "f3_1" "f4_1" "f4_2" "f5" "f3_2" "f6"
......@@ -18,51 +18,3 @@
[13] "MetFragDatabaseType = LocalCSV\nFragmentPeakMatchAbsoluteMassDeviation = 0.001\nFragmentPeakMatchRelativeMassDeviation = 5\nDatabaseSearchRelativeMassDeviation = 5\nMetFragCandidateWriter = CSV\nSampleName = testsample_a_[M+]+_a\nMaximumTreeDepth = 2\nMetFragPreProcessingCandidateFilter = UnconnectedCompoundFilter,IsotopeFilter\nMetFragPostProcessingCandidateFilter = InChIKeyFilter\nMetFragScoreTypes = FragmenterScore,OfflineIndividualMoNAScore,PubMed_Count,Patent_Count,AnnoTypeCount\nMetFragScoreWeights = 1,1,1,1,1\nIonizedPrecursorMass = 777.7789\nIsPositiveIonMode = True\nPrecursorIonMode = 0\nResultsPath = results\nPeakListPath = spec/testsample_a_[M+]+_a.csv\n\n"
[14] "MetFragDatabaseType = LocalCSV\nFragmentPeakMatchAbsoluteMassDeviation = 0.001\nFragmentPeakMatchRelativeMassDeviation = 5\nDatabaseSearchRelativeMassDeviation = 5\nMetFragCandidateWriter = CSV\nSampleName = testsample_a_[M-]-_a\nMaximumTreeDepth = 2\nMetFragPreProcessingCandidateFilter = UnconnectedCompoundFilter,IsotopeFilter\nMetFragPostProcessingCandidateFilter = InChIKeyFilter\nMetFragScoreTypes = FragmenterScore,OfflineIndividualMoNAScore,PubMed_Count,Patent_Count,AnnoTypeCount\nMetFragScoreWeights = 1,1,1,1,1\nIonizedPrecursorMass = 777.7789\nIsPositiveIonMode = False\nPrecursorIonMode = 0\nResultsPath = results\nPeakListPath = spec/testsample_a_[M-]-_a.csv\n\n"
# function metfrag_run returns correct result.
Code
ftab
Output
ID adduct tag an CE
1: 103 [M+H]+ WT 4656 10
2: 105 [M+H]+ AA 5200 10
f_conf
1: config/testsample_setNTs_ID103_adduct[M+H]+_tagWT_an4656.conf
2: config/testsample_setNTs_ID105_adduct[M+H]+_tagAA_an5200.conf
f_log
1: log/testsample_setNTs_ID103_adduct[M+H]+_tagWT_an4656.log
2: log/testsample_setNTs_ID105_adduct[M+H]+_tagAA_an5200.log
f_spec
1: spec/testsample_setNTs_ID103_adduct[M+H]+_tagWT_an4656.csv
2: spec/testsample_setNTs_ID105_adduct[M+H]+_tagAA_an5200.csv
stag
1: setNTs_ID103_adduct[M+H]+_tagWT_an4656
2: setNTs_ID105_adduct[M+H]+_tagAA_an5200
f_res
1: testsample_setNTs_ID103_adduct[M+H]+_tagWT_an4656.csv
2: testsample_setNTs_ID105_adduct[M+H]+_tagAA_an5200.csv
---
Code
x
Output
ID adduct tag an CE stag num_poss_IDs
1: 103 [M+H]+ WT 4656 10 setNTs_ID103_adduct[M+H]+_tagWT_an4656 3
2: 105 [M+H]+ AA 5200 10 setNTs_ID105_adduct[M+H]+_tagAA_an5200 79
max_Score n_Score_GE4 n_Score_GE3 n_Score_GE2 Identifier
1: 4.480685 1 1 1 7955
2: 4.923373 1 1 1 6305
CompoundName Max_FragmenterScore
1: 1,3,5-triazine-2,4,6-triamine 183.2284
2: (2S)-2-amino-3-(1H-indol-3-yl)propanoic acid 324.9085
Max_OfflineIndividualMoNAScore Max_PubMed_Count Max_Patent_Count
1: 0.80635 1740 83917
2: 0.97504 42983 320530
Max_AnnoTypeCount
1: 9
2: 9
All_Identifier
1: 7955;76318;3057066
2: 6305;54459;13596072;3292;53613696;2764164;42281871;28808413;12331302;61307511;43308922;207696;68386764;14374492;3045196;732887;1476606;231558;259193;3064503;109115;6445208;9588613;2034851;54847133;6002761;91480;3086487;3086499;3087980;67218699;231964;65932;4344644;755565;101516781;308071;24971333;206196;135436543;8551010;217642;98415;137349164;59833;3064824;907174;289049;138115391;937052;63733;89053;3032614;4444779;22348363;3054223;4098428;98889;123963;26433;97551;23511414;295571;4712703;135566968;3059780;12602;573861;13584912;91785;62140546;4255416;171417;743829;10822054;7164635;22486203;239183;135454393
# narrow_summ
Code
ns
Output
set ID precid adduct tag mz ms1_rt ms1_int Name
1: AAs 4 6 [M+H]+ AA 120.0655196 4 70481519.52 Threonine
2: AAs 4 6 [M+H]+ AA 120.0655196 4 70481519.52 Threonine
3: AAs 4 6 [M+H]+ AA 120.0655196 4 70481519.52 Threonine
4: AAs 4 26 [M+H]+ KO 120.0655196 4 80851056.09 Threonine
5: AAs 4 26 [M+H]+ KO 120.0655196 4 80851056.09 Threonine
6: AAs 4 26 [M+H]+ KO 120.0655196 4 80851056.09 Threonine
7: AAs 4 46 [M+H]+ WT 120.0655196 5 68987249.66 Threonine
8: AAs 4 46 [M+H]+ WT 120.0655196 5 68987249.66 Threonine
9: AAs 4 46 [M+H]+ WT 120.0655196 5 68987249.66 Threonine
SMILES qa_ms1_exists scan ms2_sel
1: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000058 FALSE
2: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000059 TRUE
3: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000060 FALSE
4: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000267 FALSE
5: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000268 TRUE
6: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000269 FALSE
7: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000477 FALSE
8: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000478 TRUE
9: C[C@@H](O)[C@H](N)C(O)=O TRUE F1.S000479 FALSE
# make_eic_ms1_plot
Code
plt$labels
Output
$x
[1] "retention time"
$title
[1] "MS1 EIC for ion m/z = 120.0655"
$subtitle
[1] "Threonine"
$caption
[1] "set: AAs; ID: 4"
$y
[1] "intensity"
$colour
[1] "label"
# make_eic_ms2_plot
Code
plt$labels
Output
$y
[1] "intensity"
$x
[1] "retention time"
$title
[1] "MS2 EIC for ion m/z = 120.0655"
$subtitle
[1] "Threonine"
$caption
[1] "set: AAs; ID: 4"
$ymin
[1] "ymin"
$ymax
[1] "intensity"
$colour
[1] "label"
# make_spec_ms2_plot
Code
plt$labels
Output
$x
[1] "m/z"
$title
[1] "MS2 spectra for ion m/z = 120.0655"
$subtitle
[1] "Threonine"
$caption
[1] "set: AAs; ID: 4"
$ymin
[1] "ymin"
$ymax
[1] "intensity"
$colour
[1] "label"
......@@ -58,16 +58,16 @@
out2
Output
$tag
[1] "A" "B"
character(0)
$adduct
[1] NA NA
character(0)
$set
[1] NA NA
character(0)
$file
[1] "f1.f" "f2.f"
character(0)
---
......@@ -76,16 +76,16 @@
out3
Output
$tag
[1] "X" "B"
character(0)
$adduct
[1] NA NA
character(0)
$set
[1] NA NA
character(0)
$file
[1] "f1.f" "f2.f"
character(0)
---
......@@ -94,16 +94,16 @@
out4
Output
$tag
[1] "Y" "Z"
character(0)
$adduct
[1] NA NA
character(0)
$set
[1] NA NA
character(0)
$file
[1] "fx.f" "fy.f"
character(0)
# datatab_add_files does what's intended
......
......@@ -135,7 +135,7 @@
list()
$input$tab$L0
Empty data.table (0 rows and 8 cols): ID,SMILES,Name,Formula,RT,mz...
Empty data.table (0 rows and 9 cols): ID,SMILES,Name,Formula,RT,mz...
......@@ -191,31 +191,58 @@
attr(,"class")
[1] "state"
# pack_ms2_w_summ
# pack_project
Code
res[1]
fls
Output
adduct tag ID an mz
1: [M+H]+ WT 103 4656 127.073
ms2_spectrum
1: 55.0553245544434:2729.2705078125;56.0505180358887:1269.41748046875;57.0345306396484:1185.73815917969;57.0708847045898:2073.21337890625;57.5013008117676:904.784362792969;58.0297393798828:3069.81298828125;60.0565567016602:1773.03698730469;65.0367965698242:965.617248535156;68.0254364013672:2071.56469726562;68.0505218505859:1228.7607421875;69.0344924926758:2780.85595703125;69.0709075927734:3080.65991210938;70.0662078857422:1433.41735839844;70.5652694702148:1031.4853515625;71.0502624511719:1328.03637695312;72.04541015625:1446.455078125;74.0975341796875:976.407348632812;80.5268020629883:903.040588378906;81.045768737793:15966.4443359375;81.0707244873047:3006.37255859375;82.0296325683594:1390.12121582031;82.0661010742188:21125.375;83.0500411987305:2234.1494140625;83.0613174438477:1575.17407226562;83.0865173339844:4149.6015625;84.0451507568359:2479.02978515625;84.0818328857422:1646.0302734375;85.0518188476562:43653.81640625;86.060791015625:5526.36279296875;86.0974578857422:2208.45166015625;100.039741516113:1168.80969238281;100.076499938965:10643.6787109375;108.045013427734:2149.33618164062;109.040176391602:2858.38037109375;109.065277099609:1368.20178222656;109.076728820801:4338.21337890625;109.101722717285:1770.88696289062;110.046905517578:1130.73400878906;110.060676574707:1666.49230957031;110.071846008301:1194.94689941406;110.096809387207:1337.48522949219;111.044853210449:1951.84326171875;111.056098937988:5151.44970703125;112.076545715332:2555.54321289062;114.87516784668:1056.15844726562;125.071563720703:4535.6982421875;125.083320617676:1376.74731445312;125.10807800293:1415.62915039062;126.055450439453:5190.27294921875;126.066467285156:3053.17065429688;126.09147644043:5563.90673828125;127.051559448242:31754.853515625;127.073188781738:442951.8125;128.045745849609:1565.146484375;128.055435180664:1807.43249511719;128.069152832031:19987.1328125;128.077987670898:4699.71044921875;128.107467651367:57947.6953125;128.144165039062:4561.85009765625;129.066253662109:4863.453125;129.102523803711:7756.666015625;129.110992431641:1575.72912597656;143.601974487305:1347.22827148438
[1] "test_project/file1.csv" "test_project/file2.csv"
[3] "test_project/subdir/filesubdir.csv"
# process_cmpd_sets
Code
x
Output
ID ORIG set
1: 1 f1.csv f1
2: 2 f1.csv f1
3: 3 f2.csv aks
4: 4 f3.csv se31
5: 5 f3.csv se32
---
Code
res[2]
x
Output
adduct tag ID an mz
1: [M+H]+ AA 105 5200 205.0976
ms2_spectrum
1: 60.5048713684082:19345.2421875;74.0248489379883:37208.40625;113.136558532715:23108.2421875;114.001686096191:26036.02734375;117.057220458984:32610.748046875;118.065780639648:115168.796875;130.064971923828:55615.4765625;132.081100463867:248073.703125;143.073318481445:37559.25;144.044708251953:32569.009765625;144.081192016602:481554.625;145.08512878418:71837.0546875;146.060394287109:3291220;147.064086914062:303875.53125;159.092056274414:784477.0625;160.076583862305:37691.265625;160.095474243164:73295.8515625;170.060119628906:184498.125;174.452697753906:24287.78515625;188.071014404297:18407934;189.074432373047:2457461.75;190.076156616211:145566.625;205.097793579102:497672.25;205.116928100586:29461.1640625;206.100082397461:77902.703125
ID ORIG set
1: 1 b/f2.csv f2_1
2: 2 a/f1.csv f1
3: 3 q/f/g/f2.csv aks
4: 4 d/e/f/f3.csv se31
5: 5 m/n/q/f3.csv se32
# pack_project
---
Code
fls
x
Output
[1] "test_project/file1.csv" "test_project/file2.csv"
[3] "test_project/subdir/filesubdir.csv"
ID ORIG set
1: 1 a/fn.csv fn_1
2: 2 a/fn.csv fn_1
3: 3 a/fn.csv set
4: 4 a/fn.csv set2
5: 5 a/fn.csv fn_1
6: 6 b/fn.csv fn_2
7: 7 b/fn.csv set2
8: 8 b/fn.csv set2
9: 9 b/fn.csv fn_2
---
Code
x
Output
Empty data.table (0 rows and 9 cols): ID,SMILES,Name,Formula,RT,mz...
PLOTTING_DATA <- readRDS(system.file("testdata","plotting-test-data.rds",package="shinyscreen"))
## PLOTTING_DATA <- readRDS(system.file("testdata","plotting-test-data.rds",package="shinyscreen"))
......@@ -28,7 +28,7 @@ make_dummy_mf_project <- function() {
kkk = STATE_DATA$out$tab$summ[,.(ii=.GRP),by=key(STATE_DATA$out$tab$summ)][,ii:=NULL][1:4]
m$out$tab$summ = STATE_DATA$out$tab$summ[kkk,on=key(STATE_DATA$out$tab$summ),nomatch=NULL]
m$extr = STATE_DATA$extr
m$db$extr = STATE_DATA$db$extr
m
}
......
PLOTTINGDATA <- system.file("testdata","plotting-test-data.rds")
pre_test_state = readRDS(system.file(package="shinyscreen","testdata","plotting-state.rds"))
synthetise_cgm_ms1 <- function(n,fac,shift) {
dt = data.table(rt=numeric(n),intensity=numeric(n))
dt[1L:n,rt:=seq(length.out=n)]
rt0 = dt[.N/2L + shift,rt]
dt[,intensity:=fac*exp(-((rt - rt0)/2.)**2)]
}
synthetise_cgm_ms2 <- function(cgm1,shift) {
dt = copy(cgm1)
m = dt[,max(intensity)]
n0 = dt[,.N%/%2L] + shift
dt[,intensity:=NA_real_]
dt[n0-1L,intensity:=0.05*m]
dt[n0,intensity:=0.1*m]
dt[n0+1L,intensity:=0.07*m]
dt
}
synthetise_spectra <- function(n_mz,precursors,cgm2) {
do_int <- function(n_mz,i) {
things = runif(n_mz - 1L,0.5*i,0.9*i)
c(things,i)
}
do_mass <- function(n_mz,mz) {
c(runif(n_mz-1L,0.1*mz,0.7*mz),mz)
}
cgm2[precursors,on=.(precid),
.(mz=do_mass(n_mz,i.mz),
intensity=do_int(n_mz,intensity[[1]]),
scan=scan[[1]]),
by=.EACHI]
}
synthetise_pseudo_state_db <- function(db) {
## Fix input parameters.
set.seed(22) # Random generator seed for reproducible results.
n_time = 11L
n_mz = 3L
n_precid = length(db$precursors[,unique(precid)])
n_cgm = n_time * n_precid
n_spectra = n_time * n_precid * n_mz
shifts = sample(c(-1L,0L,1L),size=n_precid,replace=T)
facs = runif(n_precid,min=0.5)*1.e8
inp = data.table(precid=db$precursors[,unique(precid)],
fac=facs,
shift=shifts)
setkey(inp,precid)
extr = list()
extr$cgm$ms1 = empty_cgram_ms1(n_cgm)
extr$cgm$ms2 = empty_cgram_ms2(n_cgm)
extr$spectra = empty_spectra_table(n_spectra)
uprec = db$precursors[,unique(.SD),.SDcols=c("file","tag","precid")]
uprec[,{
f=file
for (i in seq(length.out=length(precid))) {
b=(.GRP-1L)*length(precid)*n_time + (i-1L)*n_time + 1L
e=b+n_time - 1L
pp = precid[[i]]
cx=(.GRP-1L)*length(precid) + i
faci = inp[precid==pp,fac]
shifti = inp[precid==pp,shift]
ri = synthetise_cgm_ms1(n=n_time,
fac=faci,
shift=shifti)
ri2 = synthetise_cgm_ms2(ri,
shift=shifti)
extr$cgm$ms1[b:e,
`:=`(precid=pp,
cgmidx=cx,
file=f,
rt=ri[,rt],
intensity=ri[,intensity])]
scans = paste0("F1.S",formatC(b:e,width=6,flag="0"))
extr$cgm$ms2[b:e,
`:=`(precid=pp,
ce=50,
scan=scans,
idx=b:e,
rt=ri2[,rt],
intensity=ri2[,intensity])]
}
},
by=c("file","tag")]
extr$cgm$ms2 = extr$cgm$ms2[!is.na(intensity)]
db$extr = extr
db$extr$spectra = synthetise_spectra(n_mz,db$precursors,db$extr$cgm$ms2)
setkey(db$extr$cgm$ms1,precid,rt)
setkey(db$extr$cgm$ms2,precid,ce,rt)
setkey(db$extr$spectra,precid,scan)
set.seed(NULL)
db
}
fix_testing_state_conf <- function(conf) {
conf$prescreen$ret_time_shift_tol="5.0 min"
conf
}
## synthetise_eic_ms1 <- function(precursors) {
## ## N =
## dt = empty_cgram_ms1(
## }
pre_test_state$db = synthetise_pseudo_state_db(pre_test_state$db)
pre_test_state$conf = fix_testing_state_conf(pre_test_state$conf)
pre_test_state = prescreen(pre_test_state)
PLOTTING_TEST_STATE = pre_test_state
rm(pre_test_state)
......@@ -13,6 +13,16 @@ test_that("gen_fname_slug",{
test_that("uniqy_slugs",{
inp = c('f1','f2','f2','f2','f3','f4','f4','f5','f3','f6')
out = uniqy_slugs(inp)
message(paste(out,coll=','))
expect_snapshot(out)
})
test_that("gen_val_unc",{
vals = c(1234567,991458,256.236546546,0.2,0.002,0)
dvals = c(6733,123000,1.e-4,0.5,0.0001,0.001)
x = gen_val_unc(vals,dvals)
message("\n")
message("====")
message(paste0(x,collapse=";;"))
print("----")
expect_true(1==1)
})