diff --git a/Changelog b/Changelog index 54b99c0d..99b51783 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,8 @@ +### Added +- FASTA header verification for IonQuant + +### Changed +- New version annoucements will happpen for all updates, including minor changes + ### Fixed -- Fixed the protein coverage calculations with partially overlapping and subsumed peptides -- Fixed an issue where peptides would map to multiple locations in the protein after having I/L converted (Needs to be used with MSFragger v3.6.1 or higher) -- Fixed an issue with report tables having no isobaric labels being reported \ No newline at end of file +- Fixed an issue that would not udpate PSMs with razor IDs and description \ No newline at end of file diff --git a/Makefile b/Makefile index c07ce4e3..4578d9b7 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ BINARY = philosopher VERSION = $(shell date +%Y%m%d) BUILD = $(shell date +%Y%m%d%H%M) -TAG = v4.8.0 -RC = RC +TAG = v4.8.1 +RC = RC2 LDFLAGS = -ldflags "-w -s -extldflags -static -X main.version=${TAG} -X main.build=${BUILD}" diff --git a/lib/aba/aba.go b/lib/aba/aba.go index be693988..ba402b9b 100644 --- a/lib/aba/aba.go +++ b/lib/aba/aba.go @@ -12,13 +12,8 @@ type DataSetLabelNames struct { } // Run abacus -// TODO update error methos on the abacus function func Run(m met.Data, args []string) { - // if !m.Abacus.Peptide && !m.Abacus.Protein { - // msg.Custom(errors.New("you need to specify a peptide or protein combined file for the Abacus analysis"), "fatal") - // } - psmLevelAbacus(m, args) if m.Abacus.Peptide { @@ -29,30 +24,3 @@ func Run(m met.Data, args []string) { proteinLevelAbacus(m, args) } } - -// addCustomNames adds to the label structures user-defined names to be used on the TMT labels -// func getLabelNames(dataSet, annot string) map[string]string { - -// var labels = make(map[string]string) - -// file, e := os.Open(annot) -// if e != nil { -// msg.ReadFile(errors.New("cannot open annotation file"), "error") -// } -// defer file.Close() - -// scanner := bufio.NewScanner(file) -// for scanner.Scan() { -// names := strings.Fields(scanner.Text()) - -// name := dataSet + " " + names[0] - -// labels[name] = names[1] -// } - -// if e = scanner.Err(); e != nil { -// msg.Custom(errors.New("the annotation file looks to be empty"), "fatal") -// } - -// return labels -// } diff --git a/lib/aba/pep.go b/lib/aba/pep.go index f231c5f6..3e093f6b 100644 --- a/lib/aba/pep.go +++ b/lib/aba/pep.go @@ -54,17 +54,13 @@ func peptideLevelAbacus(m met.Data, args []string) { // collect interact full file names for _, f := range files { - //if strings.Contains(f.Name(), "pep.xml") { - //interactFile := fmt.Sprintf("%s%s%s", i, string(filepath.Separator), f.Name()) - //absPath, _ := filepath.Abs(interactFile) - //xmlFiles = append(xmlFiles, absPath) - //} + if strings.Contains(f.Name(), "annotation") { var annot = fmt.Sprintf("%s%s%s", i, string(filepath.Separator), f.Name()) file, e := os.Open(annot) if e != nil { - msg.ReadFile(errors.New("cannot open annotation file"), "error") + msg.ReadFile(errors.New("cannot open annotation file"), "fatal") } defer file.Close() @@ -78,7 +74,7 @@ func peptideLevelAbacus(m met.Data, args []string) { } if e = scanner.Err(); e != nil { - msg.Custom(errors.New("the annotation file looks to be empty"), "fatal") + msg.Custom(errors.New("the annotation file looks to be empty"), "error") } } @@ -117,7 +113,7 @@ func processPeptideCombinedFile(a met.Abacus) { if _, e := os.Stat("combined.pep.xml"); os.IsNotExist(e) { - msg.NoParametersFound(errors.New("cannot find the combined.pep.xml file"), "fatal") + msg.NoParametersFound(errors.New("cannot find the combined.pep.xml file"), "error") } else { @@ -272,7 +268,7 @@ func savePeptideAbacusResult(session string, evidences rep.CombinedPeptideEviden // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "error") + msg.WriteFile(e, "fatal") } defer file.Close() @@ -286,7 +282,7 @@ func savePeptideAbacusResult(session string, evidences rep.CombinedPeptideEviden line += "\n" _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } // organize by group number @@ -328,7 +324,7 @@ func savePeptideAbacusResult(session string, evidences rep.CombinedPeptideEviden line += "\n" _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } diff --git a/lib/aba/pro.go b/lib/aba/pro.go index 5c184362..640ba7fc 100644 --- a/lib/aba/pro.go +++ b/lib/aba/pro.go @@ -60,7 +60,7 @@ func proteinLevelAbacus(m met.Data, args []string) { file, e := os.Open(annot) if e != nil { - msg.ReadFile(errors.New("cannot open annotation file"), "error") + msg.ReadFile(errors.New("cannot open annotation file"), "fatal") } defer file.Close() @@ -74,7 +74,7 @@ func proteinLevelAbacus(m met.Data, args []string) { } if e = scanner.Err(); e != nil { - msg.Custom(errors.New("the annotation file looks to be empty"), "fatal") + msg.Custom(errors.New("the annotation file looks to be empty"), "error") } } } @@ -157,7 +157,7 @@ func processProteinCombinedFile(a met.Abacus, database dat.Base) rep.CombinedPro if _, e := os.Stat("combined.prot.xml"); os.IsNotExist(e) { - msg.Custom(errors.New("cannot find combined.prot.xml file"), "fatal") + msg.Custom(errors.New("cannot find combined.prot.xml file"), "error") } else { @@ -409,7 +409,7 @@ func saveProteinAbacusResult(session, plex string, evidences rep.CombinedProtein // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "error") + msg.WriteFile(e, "fatal") } defer file.Close() @@ -464,7 +464,7 @@ func saveProteinAbacusResult(session, plex string, evidences rep.CombinedProtein } else if plex == "18" { chs = append(chs, "126", "127N", "127C", "128N", "128C", "129N", "129C", "130N", "130C", "131N", "131C", "132N", "132C", "133N", "133C", "134N", "134C", "135N") } else { - msg.Custom(errors.New("unsupported number of labels"), "fatal") + msg.Custom(errors.New("unsupported number of labels"), "error") } if hasLabels { @@ -486,7 +486,7 @@ func saveProteinAbacusResult(session, plex string, evidences rep.CombinedProtein header += "\n" _, e = io.WriteString(file, header) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } for _, i := range evidences { @@ -631,7 +631,7 @@ func saveProteinAbacusResult(session, plex string, evidences rep.CombinedProtein line += "\n" _, e := io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } @@ -651,7 +651,7 @@ func saveReprintSpCResults(session, plex string, evidences rep.CombinedProteinEv // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(errors.New("cannot create reprint SpC report"), "error") + msg.WriteFile(errors.New("cannot create reprint SpC report"), "fatal") } defer file.Close() @@ -672,7 +672,7 @@ func saveReprintSpCResults(session, plex string, evidences rep.CombinedProteinEv _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } // organize by group number @@ -691,7 +691,7 @@ func saveReprintSpCResults(session, plex string, evidences rep.CombinedProteinEv line += "\n" _, e := io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } @@ -710,7 +710,7 @@ func saveReprintIntResults(session, plex string, evidences rep.CombinedProteinEv // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(errors.New("cannot create reprint Int. report"), "error") + msg.WriteFile(errors.New("cannot create reprint Int. report"), "fatal") } defer file.Close() @@ -731,7 +731,7 @@ func saveReprintIntResults(session, plex string, evidences rep.CombinedProteinEv _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } // organize by group number @@ -750,7 +750,7 @@ func saveReprintIntResults(session, plex string, evidences rep.CombinedProteinEv line += "\n" _, e := io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } diff --git a/lib/aba/psm.go b/lib/aba/psm.go index ceb6afe2..efbb3431 100644 --- a/lib/aba/psm.go +++ b/lib/aba/psm.go @@ -43,7 +43,7 @@ func psmLevelAbacus(m met.Data, args []string) { file, e := os.Open(annot) if e != nil { - msg.ReadFile(errors.New("cannot open annotation file"), "error") + msg.ReadFile(errors.New("cannot open annotation file"), "fatal") } defer file.Close() @@ -57,7 +57,7 @@ func psmLevelAbacus(m met.Data, args []string) { } if e = scanner.Err(); e != nil { - msg.Custom(errors.New("the annotation file looks to be empty"), "fatal") + msg.Custom(errors.New("the annotation file looks to be empty"), "error") } } } @@ -122,7 +122,7 @@ func savePSMAbacusResult(session, plex string, evidences rep.CombinedPSMEvidence // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "error") + msg.WriteFile(e, "fatal") } defer file.Close() @@ -144,7 +144,7 @@ func savePSMAbacusResult(session, plex string, evidences rep.CombinedPSMEvidence } else if plex == "18" { chs = append(chs, "126", "127N", "127C", "128N", "128C", "129N", "129C", "130N", "130C", "131N", "131C", "132N", "132C", "133N", "133C", "134N", "134C", "135N") } else { - msg.Custom(errors.New("unsupported number of labels"), "fatal") + msg.Custom(errors.New("unsupported number of labels"), "error") } if hasLabels { @@ -164,7 +164,7 @@ func savePSMAbacusResult(session, plex string, evidences rep.CombinedPSMEvidence header += "\n" _, e = io.WriteString(file, header) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } for _, i := range evidences { @@ -267,7 +267,7 @@ func savePSMAbacusResult(session, plex string, evidences rep.CombinedPSMEvidence line += "\n" _, e := io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } diff --git a/lib/bio/bio_test.go b/lib/bio/bio_test.go index 45d92f9d..b3173240 100644 --- a/lib/bio/bio_test.go +++ b/lib/bio/bio_test.go @@ -112,13 +112,6 @@ func TestAminoAcids(t *testing.T) { } -// func TestProtonMass(t *testing.T) { -// p := Proton -// if p != float64(1.007276) { -// t.Errorf("Proton mass is incorrect, got %f, want %f", p, 1.007276) -// } -// } - func TestEnzymes(t *testing.T) { tes.SetupTestEnv() diff --git a/lib/dat/dat.go b/lib/dat/dat.go index 0d012411..f0c4aed3 100644 --- a/lib/dat/dat.go +++ b/lib/dat/dat.go @@ -56,7 +56,7 @@ func Run(m met.Data) met.Data { var db = New() if len(m.Database.ID) == 0 && (len(m.Database.Annot) == 0 || m.Database.Annot == "--contam" || m.Database.Annot == "--prefix") && (len(m.Database.Custom) == 0 || m.Database.Custom == "--contam" || m.Database.Custom == "--prefix") { - msg.InputNotFound(errors.New("provide a protein FASTA file or Proteome ID"), "fatal") + msg.InputNotFound(errors.New("provide a protein FASTA file or Proteome ID"), "error") } if len(m.Database.Annot) > 0 { @@ -73,7 +73,7 @@ func Run(m met.Data) met.Data { } if len(m.Database.ID) < 1 && len(m.Database.Custom) < 1 { - msg.InputNotFound(errors.New("you need to provide a taxon ID or a custom FASTA file"), "fatal") + msg.InputNotFound(errors.New("you need to provide a taxon ID or a custom FASTA file"), "error") } if !m.Database.Crap { @@ -139,6 +139,11 @@ func (d *Base) ProcessDB(file, decoyTag string) { class := Classify(k, decoyTag) + if strings.Contains(k, "@") { + m := "The proteion record [" + k + "] contains an unsupported character: @. Please remove it before running philosopher again" + msg.Custom(errors.New(m), "error") + } + if class == "uniprot" { db := ProcessUniProtKB(k, v, decoyTag) @@ -175,7 +180,7 @@ func (d *Base) ProcessDB(file, decoyTag string) { d.Records = append(d.Records, db) } else { - msg.ParsingFASTA(errors.New(""), "fatal") + msg.ParsingFASTA(errors.New(""), "error") } } @@ -241,14 +246,14 @@ func (d *Base) Fetch(uniprotID, proteomeID, temp string, iso, rev bool) { // tries to create an output file output, e := os.Create(d.UniProtDB) if e != nil { - msg.WriteFile(errors.New("cannot create a local database file"), "fatal") + msg.WriteFile(errors.New("cannot create a local database file"), "error") } defer output.Close() // tries to download data from Uniprot _, e = io.Copy(output, gz) if e != nil { - msg.Custom(errors.New("UniProt download failed, please check your connection"), "fatal") + msg.Custom(errors.New("UniProt download failed, please check your connection"), "error") } d.DownloadedFiles = append(d.DownloadedFiles, d.UniProtDB) @@ -327,12 +332,12 @@ func (d *Base) Deploy(temp string) { param, e1 := Asset("crap-gpmdb.fas") if e1 != nil { - msg.WriteFile(e1, "fatal") + msg.WriteFile(e1, "error") } e2 := ioutil.WriteFile(d.CrapDB, param, sys.FilePermission()) if e2 != nil { - msg.WriteFile(e2, "fatal") + msg.WriteFile(e2, "error") } } @@ -346,12 +351,12 @@ func GetOrganismID(temp string, uniprotID string) (string, string) { param, e1 := Asset("proteomes.csv") if e1 != nil { - msg.WriteFile(e1, "fatal") + msg.WriteFile(e1, "error") } e2 := ioutil.WriteFile(proteomeFile, param, sys.FilePermission()) if e2 != nil { - msg.WriteFile(e2, "fatal") + msg.WriteFile(e2, "error") } f, e := os.Open(proteomeFile) @@ -408,7 +413,7 @@ func (d *Base) Save(home, temp, ids, tag string, isRev, hasIso, noD, Crap bool) // create db file file, e := os.Create(workfile) if e != nil { - msg.ReadFile(errors.New("cannot open the database file"), "fatal") + msg.ReadFile(errors.New("cannot open the database file"), "error") } defer file.Close() @@ -423,7 +428,7 @@ func (d *Base) Save(home, temp, ids, tag string, isRev, hasIso, noD, Crap bool) line := i + "\n" + d.TaDeDB[i] + "\n" _, e = io.WriteString(file, line) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } } @@ -437,12 +442,12 @@ func (d *Base) Serialize() { b, e := msgpack.Marshal(&d) if e != nil { - msg.MarshalFile(e, "fatal") + msg.MarshalFile(e, "error") } e = ioutil.WriteFile(sys.DBBin(), b, sys.FilePermission()) if e != nil { - msg.SerializeFile(e, "fatal") + msg.SerializeFile(e, "error") } } diff --git a/lib/dat/db.go b/lib/dat/db.go index 03e4cc3e..8df47974 100644 --- a/lib/dat/db.go +++ b/lib/dat/db.go @@ -282,7 +282,7 @@ func ProcessUniProtKB(k, v, decoyTag string) Record { if strings.Contains(k, "GN=") && (strings.Contains(k, "PE=") || strings.Contains(k, "SV=")) { if len(orn) < 2 { - msg.ParsingFASTA(errors.New(""), "fatal") + msg.ParsingFASTA(errors.New(""), "error") } gnReg := regexp.MustCompile(`GN=(.+?)(\s.+)`) diff --git a/lib/ext/comet/comet.go b/lib/ext/comet/comet.go index 41e3fc04..2ad58b37 100644 --- a/lib/ext/comet/comet.go +++ b/lib/ext/comet/comet.go @@ -49,7 +49,7 @@ func Run(m met.Data, args []string) met.Data { var cmt = New(m.Temp) if len(m.Comet.Param) < 1 || !m.Comet.Print && len(args) < 1 { - msg.Comet(errors.New(""), "fatal") + msg.Comet(errors.New(""), "error") } // deploy the binaries @@ -69,7 +69,7 @@ func Run(m met.Data, args []string) met.Data { paramAbs, _ := filepath.Abs(m.Comet.Param) binFile, e := ioutil.ReadFile(paramAbs) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } m.Comet.ParamFile = binFile diff --git a/lib/ext/interprophet/interprophet.go b/lib/ext/interprophet/interprophet.go index b0bae24a..c950722a 100644 --- a/lib/ext/interprophet/interprophet.go +++ b/lib/ext/interprophet/interprophet.go @@ -42,7 +42,7 @@ func Run(m met.Data, args []string) met.Data { m.InterProphet.InputFiles = args if len(args) < 1 { - msg.NoParametersFound(errors.New("IProphet input files"), "fatal") + msg.NoParametersFound(errors.New("IProphet input files"), "error") } // deploy the binaries @@ -90,12 +90,12 @@ func (i InterProphet) Execute(params met.InterProphet, home, temp string, args [ cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() if cmd.ProcessState.ExitCode() != 0 { - msg.ExecutingBinary(errors.New("there was an error with iProphet, please check your parameters and input files"), "fatal") + msg.ExecutingBinary(errors.New("there was an error with iProphet, please check your parameters and input files"), "error") } // copy to work directory diff --git a/lib/ext/interprophet/interprophet_unix.go b/lib/ext/interprophet/interprophet_unix.go index 1f4aba81..2ec7c7f9 100644 --- a/lib/ext/interprophet/interprophet_unix.go +++ b/lib/ext/interprophet/interprophet_unix.go @@ -22,6 +22,6 @@ func (i *InterProphet) Deploy(distro string) { unix.UnixInterProphetParser(i.UnixInterProphetParser) i.DefaultInterProphetParser = i.UnixInterProphetParser } else { - msg.UnsupportedDistribution(errors.New(""), "fatal") + msg.UnsupportedDistribution(errors.New(""), "error") } } diff --git a/lib/ext/msfragger/msfragger.go b/lib/ext/msfragger/msfragger.go index c63d0cdf..dcdb8489 100644 --- a/lib/ext/msfragger/msfragger.go +++ b/lib/ext/msfragger/msfragger.go @@ -42,7 +42,7 @@ func Run(m met.Data, args []string) met.Data { paramAbs, _ := filepath.Abs(m.MSFragger.Param) binFile, e := ioutil.ReadFile(paramAbs) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } m.MSFragger.ParamFile = binFile } @@ -71,7 +71,7 @@ func (c *MSFragger) Execute(params met.MSFragger, cmdArgs []string) { cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() @@ -100,7 +100,7 @@ func (c *MSFragger) ExecutewithParameter(params met.MSFragger, cmdArgs []string) cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() diff --git a/lib/ext/peptideprophet/peptideprophet.go b/lib/ext/peptideprophet/peptideprophet.go index f3386dbe..33318017 100644 --- a/lib/ext/peptideprophet/peptideprophet.go +++ b/lib/ext/peptideprophet/peptideprophet.go @@ -52,7 +52,7 @@ func Run(m met.Data, args []string) met.Data { var pep = New(m.Temp) // if len(m.PeptideProphet.Database) < 1 { - // msg.Custom(errors.New("You need to provide a protein database"), "fatal") + // msg.Custom(errors.New("You need to provide a protein database"), "error") // } // get the database tag from database command @@ -165,7 +165,7 @@ func interactParser(p PeptideProphet, params met.PeptideProphet, home, temp stri cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() @@ -221,18 +221,18 @@ func interactParser(p PeptideProphet, params met.PeptideProphet, home, temp stri e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } // out, e := cmd.CombinedOutput() // if e != nil { - // msg.ExecutingBinary(e, "fatal") + // msg.ExecutingBinary(e, "error") // } _ = cmd.Wait() if cmd.ProcessState.ExitCode() != 0 { - msg.ExecutingBinary(errors.New("there was an error with PeptideProphet, please check your parameters and input files"), "fatal") + msg.ExecutingBinary(errors.New("there was an error with PeptideProphet, please check your parameters and input files"), "error") } } @@ -273,7 +273,7 @@ func refreshParser(p PeptideProphet, file, database, output, temp string) { cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() } @@ -447,7 +447,7 @@ func peptideProphet(p PeptideProphet, params met.PeptideProphet, temp, file stri cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() diff --git a/lib/ext/peptideprophet/peptideprophet_unix.go b/lib/ext/peptideprophet/peptideprophet_unix.go index 84a39394..d637a598 100644 --- a/lib/ext/peptideprophet/peptideprophet_unix.go +++ b/lib/ext/peptideprophet/peptideprophet_unix.go @@ -30,6 +30,6 @@ func (p *PeptideProphet) Deploy(distro string) { unix.UnixPeptideProphetParser(p.UnixPeptideProphetParser) p.DefaultPeptideProphetParser = p.UnixPeptideProphetParser } else { - msg.UnsupportedDistribution(errors.New(""), "fatal") + msg.UnsupportedDistribution(errors.New(""), "error") } } diff --git a/lib/ext/proteinprophet/deploy_unix.go b/lib/ext/proteinprophet/deploy_unix.go index 96947169..1d6a532f 100644 --- a/lib/ext/proteinprophet/deploy_unix.go +++ b/lib/ext/proteinprophet/deploy_unix.go @@ -29,6 +29,6 @@ func (p *ProteinProphet) Deploy(distro string) { unix.UnixProteinProphet(p.UnixProteinProphet) p.DefaultProteinProphet = p.UnixProteinProphet } else { - msg.UnsupportedDistribution(errors.New(""), "fatal") + msg.UnsupportedDistribution(errors.New(""), "error") } } diff --git a/lib/ext/proteinprophet/proteinprophet.go b/lib/ext/proteinprophet/proteinprophet.go index b95bb3d0..e0036a1f 100644 --- a/lib/ext/proteinprophet/proteinprophet.go +++ b/lib/ext/proteinprophet/proteinprophet.go @@ -52,7 +52,7 @@ func Run(m met.Data, args []string) met.Data { var pop = New(m.Temp) if len(args) < 1 { - msg.NoParametersFound(errors.New("missing pep.xml"), "fatal") + msg.NoParametersFound(errors.New("missing pep.xml"), "error") } // deploy the binaries @@ -102,12 +102,12 @@ func (p ProteinProphet) Execute(params met.ProteinProphet, home, temp string, ar cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() if cmd.ProcessState.ExitCode() != 0 { - msg.ExecutingBinary(errors.New("there was an error with ProteinProphet, please check your parameters and input files"), "fatal") + msg.ExecutingBinary(errors.New("there was an error with ProteinProphet, please check your parameters and input files"), "error") } // copy to work directory diff --git a/lib/ext/ptmprophet/ptmprophet.go b/lib/ext/ptmprophet/ptmprophet.go index b4dfc80a..200ebb3e 100644 --- a/lib/ext/ptmprophet/ptmprophet.go +++ b/lib/ext/ptmprophet/ptmprophet.go @@ -83,15 +83,10 @@ func (p *PTMProphet) Execute(params met.PTMProphet, args []string) []string { e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() - // if cmd.ProcessState.ExitCode() != 0 { - // fmt.Println(cmd.Stdout, cmd.Stderr) - // msg.ExecutingBinary(errors.New("there was an error with PTMProphet, please check your parameters and input files"), "fatal") - // } - // collect all resulting files var customOutput []string if params.KeepOld { diff --git a/lib/ext/ptmprophet/ptmprophet_unix.go b/lib/ext/ptmprophet/ptmprophet_unix.go index dd494581..b451b857 100644 --- a/lib/ext/ptmprophet/ptmprophet_unix.go +++ b/lib/ext/ptmprophet/ptmprophet_unix.go @@ -21,6 +21,6 @@ func (p *PTMProphet) Deploy(distro string) { unix.UnixPTMProphetParser(p.UnixPTMProphetParser) p.DefaultPTMProphetParser = p.UnixPTMProphetParser } else { - msg.UnsupportedDistribution(errors.New(""), "fatal") + msg.UnsupportedDistribution(errors.New(""), "error") } } diff --git a/lib/ext/tmtintegrator/tmtintegrator.go b/lib/ext/tmtintegrator/tmtintegrator.go index 9f13870b..60cd1f9c 100644 --- a/lib/ext/tmtintegrator/tmtintegrator.go +++ b/lib/ext/tmtintegrator/tmtintegrator.go @@ -42,7 +42,7 @@ func Run(m met.Data, args []string) met.Data { paramAbs, _ := filepath.Abs(m.TMTIntegrator.Param) binFile, e := ioutil.ReadFile(paramAbs) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } m.TMTIntegrator.ParamFile = binFile } @@ -67,7 +67,7 @@ func (c *TMTIntegrator) Execute(params met.TMTIntegrator, cmdArgs []string) { cmd.Stderr = os.Stderr e := cmd.Start() if e != nil { - msg.ExecutingBinary(e, "fatal") + msg.ExecutingBinary(e, "error") } _ = cmd.Wait() diff --git a/lib/fas/fas.go b/lib/fas/fas.go index b166d816..9fde3cb8 100644 --- a/lib/fas/fas.go +++ b/lib/fas/fas.go @@ -19,7 +19,7 @@ func ParseFile(filename string) map[string]string { f, e := os.Open(filename) if filename == "" || e != nil { - msg.ReadFile(errors.New("cannot open the database file"), "error") + msg.ReadFile(errors.New("cannot open the database file"), "fatal") } defer f.Close() @@ -84,7 +84,7 @@ func ParseFastaDescription(filename string) map[string][]string { f, e := os.Open(filename) if filename == "" || e != nil { - msg.ReadFile(errors.New("cannot open FASTA file"), "fatal") + msg.ReadFile(errors.New("cannot open FASTA file"), "error") } defer f.Close() diff --git a/lib/fil/fdr.go b/lib/fil/fdr.go index 1adcfc15..075bfab9 100644 --- a/lib/fil/fdr.go +++ b/lib/fil/fdr.go @@ -537,7 +537,7 @@ func ProtXMLFilter(p id.ProtXML, targetFDR, pepProb, protProb float64, isPicked, } if currentTopPepProb == 10 { - msg.Custom(errors.New("the protein FDR filter didn't reach the desired threshold, try a higher threshold using the --prot parameter"), "error") + msg.Custom(errors.New("the protein FDR filter didn't reach the desired threshold, try a higher threshold using the --prot parameter"), "fatal") } // if the current protein block threshold is below the threshold, we look for the next one diff --git a/lib/fil/fil.go b/lib/fil/fil.go index 7a81220b..f0e8790a 100644 --- a/lib/fil/fil.go +++ b/lib/fil/fil.go @@ -102,6 +102,7 @@ func Run(f met.Data) met.Data { } var pepxml id.PepXML pepxml.Restore() + // restoring for the modifications e.Mods = pepxml.Modifications e.AssembleSearchParameters(pepxml.SearchParameters) @@ -149,7 +150,6 @@ func Run(f met.Data) met.Data { // evaluate modifications in data set if f.Filter.Mapmods { - //e.UpdateIonModCount() e.UpdatePeptideModCount() } @@ -607,9 +607,6 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin pro.Length = 0 pro.PercentCoverage = float32(coverMap[pro.ProteinName]) - //pro.PctSpectrumIDs = 0.0 - //pro.GroupProbability = 1.00 - //pro.Confidence = 1.00 pro.HasRazor = true if i.Probability > pro.Probability { @@ -625,9 +622,6 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin if !ok { pro.Length = 0 pro.PercentCoverage = float32(coverMap[pro.ProteinName]) - //pro.PctSpectrumIDs = 0.0 - //pro.GroupProbability = 1.00 - //pro.Confidence = 1.00 pro.HasRazor = false if i.Probability > pro.Probability { @@ -645,7 +639,6 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin //var addedIon = make(map[string]uint8) for _, i := range psm { - //ionForm := fmt.Sprintf("%s#%d#%.4f", i.Peptide, i.AssumedCharge, i.CalcNeutralPepMass) pro := proteinList[i.Protein] razorProtein, ok := razorMap[i.Peptide] @@ -661,8 +654,7 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin Weight: 1, GroupWeight: 0, CalcNeutralPepMass: i.CalcNeutralPepMass, - //SharedParentProteins: len(i.AlternativeProteins), - Razor: 1, + Razor: 1, } for j := range i.AlternativeProteins { @@ -670,17 +662,13 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin pro.IndistinguishableProtein = append(pro.IndistinguishableProtein, j) } - //pep.NumberOfInstances++ - if i.Probability > pep.InitialProbability { pep.InitialProbability = i.Probability } if len(i.AlternativeProteins) < 2 { - //pep.IsNondegenerateEvidence = true pep.IsUnique = true } else { - //pep.IsNondegenerateEvidence = false pep.IsUnique = false } @@ -689,7 +677,6 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin pep.Modifications.Index[k] = v } - //pro.IndistinguishableProtein = i.AlternativeProteins pro.HasRazor = true pro.PeptideIons = append(pro.PeptideIons, pep) @@ -707,23 +694,16 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin Weight: 0, GroupWeight: 0, CalcNeutralPepMass: i.CalcNeutralPepMass, - //SharedParentProteins: len(i.AlternativeProteins), - Razor: 0, + Razor: 0, } if i.Probability > pep.InitialProbability { pep.InitialProbability = i.Probability } - //pep.PeptideParentProtein = i.AlternativeProteins - - //pep.NumberOfInstances++ - if len(i.AlternativeProteins) < 2 { - //pep.IsNondegenerateEvidence = true pep.IsUnique = true } else { - //pep.IsNondegenerateEvidence = false pep.IsUnique = false } @@ -732,7 +712,6 @@ func processProteinInferenceIdentifications(psm id.PepIDList, razorMap map[strin pep.Modifications.Index[k] = v } - //pro.IndistinguishableProtein = i.AlternativeProteins pro.PeptideIons = append(pro.PeptideIons, pep) proteinList[i.Protein] = pro diff --git a/lib/fin/fin.go b/lib/fin/fin.go index 25f6e42e..af82409a 100644 --- a/lib/fin/fin.go +++ b/lib/fin/fin.go @@ -203,7 +203,7 @@ type RunHeader struct { Unknown34 uint32 } -//SampleInfo contains some other info +// SampleInfo contains some other info type SampleInfo struct { Unknown1 uint32 Unknown2 uint32 @@ -307,7 +307,7 @@ type ScanDataPacket struct { Triplets []float32 } -//PeakDescriptor is a struct containing more info about the peaks +// PeakDescriptor is a struct containing more info about the peaks type PeakDescriptor struct { Index uint16 Flags uint8 @@ -511,7 +511,7 @@ func (rd *RawData) ProcessRaw(f string) { file, e := os.Open(f) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } // Read headers for file version and RunHeader addresses. @@ -766,7 +766,7 @@ func (data *RunHeader) Retrieve(rs io.ReadSeeker, info RawFileInfo, ver Version) } if data.ScantrailerAddr == 0 { - msg.Custom(errors.New(""), "fatal") + msg.Custom(errors.New(""), "error") } } @@ -776,7 +776,7 @@ func (data *InstID) Retrieve(rs io.ReadSeeker, pos uint64, ver Version) { data.Address = readAt(rs, pos, ver, data) } -//// Readers +// // Readers func (data *RunHeader) Read(r io.Reader, v Version) { binaryread(r, &data.SampleInfo) @@ -1238,14 +1238,14 @@ func readAt(rs io.ReadSeeker, pos uint64, v Version, data reader) uint64 { _, e1 := rs.Seek(int64(pos), 0) if e1 != nil { - msg.Custom(errors.New("error seeking file"), "fatal") + msg.Custom(errors.New("error seeking file"), "error") } data.Read(rs, v) spos, e2 := rs.Seek(0, 1) if e2 != nil { - msg.Custom(errors.New("error determining position in file"), "fatal") + msg.Custom(errors.New("error determining position in file"), "error") } return uint64(spos) @@ -1257,7 +1257,7 @@ func readBetween(rs io.ReadSeeker, begin uint64, end uint64, v Version, data rea _, e := rs.Seek(int64(begin), 0) if e != nil { - msg.Custom(errors.New("error seeking file"), "fatal") + msg.Custom(errors.New("error seeking file"), "error") } // may fail because of memory requirements diff --git a/lib/gth/gth.go b/lib/gth/gth.go index 669ed8cc..8415f298 100644 --- a/lib/gth/gth.go +++ b/lib/gth/gth.go @@ -39,7 +39,7 @@ func UpdateChecker(v, b string) { body, e := ioutil.ReadAll(res.Body) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } var rel Releases @@ -50,23 +50,16 @@ func UpdateChecker(v, b string) { } else { - local := strings.Split(v, ".") - local[0] = strings.Replace(local[0], "v", "", 1) + local := strings.Replace(v, ".", "", -1) + local = strings.Replace(local, "v", "", 1) - remote := strings.Split(rel[0].TagName, ".") - remote[0] = strings.Replace(remote[0], "v", "", 1) + remote := strings.Replace(rel[0].TagName, ".", "", -1) + remote = strings.Replace(remote, "v", "", 1) - outdatedMajorVersion := remote[0] > local[0] - //outdatedMinorVersion := (remote[0] == local[0]) && (remote[1] > local[1]) - //outdated := outdatedMajorVersion || outdatedMinorVersion - - outdated := outdatedMajorVersion - - if outdated { + if remote > local { logrus.Warning("There is a new version of Philosopher available for download: https://github.com/Nesvilab/philosopher/releases") } } } - } diff --git a/lib/id/pep.go b/lib/id/pep.go index bb456b01..b8f5efa2 100644 --- a/lib/id/pep.go +++ b/lib/id/pep.go @@ -213,13 +213,11 @@ func (p *PepXML) Read(f string) { _, ok := p.Modifications.Index[key] if !ok { m := mod.Modification{ - Index: key, - Type: mod.Assigned, - //MonoIsotopicMass: i.Mass, + Index: key, + Type: mod.Assigned, MassDiff: uti.ToFixed(i.MassDiff, 4), Variable: variable, AminoAcid: string(i.AminoAcid), - //IsobaricMods: make(map[string]float64), } p.Modifications.Index[key] = m @@ -239,15 +237,11 @@ func (p *PepXML) Read(f string) { if !ok { m := mod.Modification{ - Index: key, - Type: mod.Assigned, - //MonoIsotopicMass: i.Mass, + Index: key, + Type: mod.Assigned, MassDiff: uti.ToFixed(i.MassDiff, 4), Variable: variable, AminoAcid: fmt.Sprintf("%s-term", i.Terminus), - //IsProteinTerminus: string(i.ProteinTerminus), - //Terminus: strings.ToLower(string(i.Terminus)), - //IsobaricMods: make(map[string]float64), } p.Modifications.Index[key] = m @@ -299,7 +293,7 @@ func ReadPepXMLInput(xmlFile, decoyTag, temp string, models bool) (PepIDListPtrs list := uti.IOReadDir(xmlFile, "pep.xml") if len(list) == 0 { - msg.NoParametersFound(errors.New("missing PeptideProphet pepXML files"), "fatal") + msg.NoParametersFound(errors.New("missing PeptideProphet pepXML files"), "error") } // in case both PeptideProphet and PTMProphet files are present, use @@ -438,12 +432,6 @@ func processSpectrumQuery(sq spc.SpectrumQuery, mods mod.Modifications, decoyTag psm.Probability = j.PeptideProphetResult.Probability - // for _, k := range j.PeptideProphetResult.SearchScoreSummary.Parameter { - - // if k.Name == "massd" { - // //psm.IsoMassD, _ = strconv.Atoi(k.Value) - // } - // } } if string(j.Analysis) == "interprophet" { @@ -475,12 +463,6 @@ func processSpectrumQuery(sq spc.SpectrumQuery, mods mod.Modifications, decoyTag } else if string(j.Name) == "deltacn" { value, _ := strconv.ParseFloat(j.Value, 64) psm.DeltaCN = value - } else if string(j.Name) == "deltacnstar" { - //value, _ := strconv.ParseFloat(j.Value, 64) - //psm.DeltaCNStar = value - } else if string(j.Name) == "spscore" { - //value, _ := strconv.ParseFloat(j.Value, 64) - //psm.SPScore = value } else if string(j.Name) == "sprank" { value, _ := strconv.ParseFloat(j.Value, 64) psm.SPRank = value @@ -614,27 +596,6 @@ func (p *PeptideIdentification) mapModsFromPepXML(m spc.ModificationInfo, mods m } } -// getMassDeviation calculates the mass deviation for a pepXML file based on the 0 mass difference -// func getMassDeviation(sq []spc.SpectrumQuery) float64 { - -// var countZero int -// var massZero float64 -// var adjustedMass float64 - -// for _, i := range sq { -// for _, j := range i.SearchResult.SearchHit { -// if math.Abs(j.Massdiff) >= -0.1 && math.Abs(j.Massdiff) <= 0.1 { -// countZero++ -// massZero += j.Massdiff -// } -// } -// } - -// adjustedMass = massZero / float64(countZero) - -// return adjustedMass -// } - // PromoteProteinIDs changes the identification in cases where the reference protein is a decoy and // the alternative proteins contains target proteins. func (p *PepXML4Serialiazation) PromoteProteinIDs() { @@ -854,7 +815,7 @@ func (p *PepIDList) Serialize(level string) { } else if level == "ion" { dest = sys.IonBin() } else { - msg.Custom(errors.New("cannot determine binary data class"), "fatal") + msg.Custom(errors.New("cannot determine binary data class"), "error") } sys.Serialize(p, dest) } @@ -871,7 +832,7 @@ func (p *PepIDListPtrs) Serialize(level string) { } else if level == "ion" { dest = sys.IonBin() } else { - msg.Custom(errors.New("cannot determine binary data class"), "fatal") + msg.Custom(errors.New("cannot determine binary data class"), "error") } sys.Serialize(p, dest) } @@ -888,7 +849,7 @@ func (p *PepIDList) Restore(level string) { } else if level == "ion" { dest = sys.IonBin() } else { - msg.Custom(errors.New("cannot determine binary data class"), "fatal") + msg.Custom(errors.New("cannot determine binary data class"), "error") } sys.Restore(p, dest, false) } diff --git a/lib/id/pro.go b/lib/id/pro.go index c10ff9ed..d08ee56b 100644 --- a/lib/id/pro.go +++ b/lib/id/pro.go @@ -109,7 +109,7 @@ func (p ProtIDList) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -// Read ... +// Read is the mmain function to read prot.xml files func (p *ProtXML) Read(f string) { var xml spc.ProtXML @@ -213,7 +213,7 @@ func (p *ProtXML) Read(f string) { p.Groups = groups if len(groups) == 0 { - msg.NoProteinFound(errors.New(""), "fatal") + msg.NoProteinFound(errors.New(""), "error") } } diff --git a/lib/met/met.go b/lib/met/met.go index 1523f724..b198a054 100644 --- a/lib/met/met.go +++ b/lib/met/met.go @@ -480,7 +480,7 @@ func CleanTemp(dir string) { e := os.RemoveAll(dir) if e != nil { - msg.Custom(e, "error") + msg.Custom(e, "fatal") } } @@ -489,12 +489,12 @@ func (d *Data) Serialize() { b, e := msgpack.Marshal(&d) if e != nil { - msg.MarshalFile(e, "fatal") + msg.MarshalFile(e, "error") } e = ioutil.WriteFile(sys.Meta(), b, sys.FilePermission()) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } } @@ -524,7 +524,7 @@ func (d *Data) Restore(f string) { func (d Data) FunctionInitCheckUp() { if len(d.UUID) < 1 && len(d.Home) < 1 { - msg.WorkspaceNotFound(errors.New("failed to checkup the initialization"), "fatal") + msg.WorkspaceNotFound(errors.New("failed to checkup the initialization"), "error") } if _, e := os.Stat(d.Temp); os.IsNotExist(e) && len(d.UUID) > 0 { diff --git a/lib/mod/mod.go b/lib/mod/mod.go index d4b0c2a2..60f895ea 100644 --- a/lib/mod/mod.go +++ b/lib/mod/mod.go @@ -24,10 +24,6 @@ type Modification struct { Position int Type ModTypeType Variable bool - //IsProteinTerminus string - //Terminus string - //MonoIsotopicMass float64 - //AverageMass float64 } // Modifications is a collection of modifications @@ -52,31 +48,3 @@ func (m ModificationsSlice) ToMap() Modifications { } return Modifications{Index: Index} } - -// Serialize saves to disk a msgpack version of the Isobaric data structure -// func (m *Modifications) Serialize() { - -// b, e := msgpack.Marshal(&m) -// if e != nil { -// msg.MarshalFile(e, "fatal") -// } - -// e = ioutil.WriteFile(sys.EvModificationsBin(), b, sys.FilePermission()) -// if e != nil { -// msg.SerializeFile(e, "fatal") -// } -// } - -// Restore reads philosopher results files and restore the data sctructure -// func (m *Modifications) Restore() { - -// b, e := ioutil.ReadFile(sys.EvModificationsBin()) -// if e != nil { -// msg.MarshalFile(e, "warning") -// } - -// e = msgpack.Unmarshal(b, &m) -// if e != nil { -// msg.SerializeFile(e, "warning") -// } -// } diff --git a/lib/msg/msg.go b/lib/msg/msg.go index 25c9fef7..1aa3f8d2 100644 --- a/lib/msg/msg.go +++ b/lib/msg/msg.go @@ -312,10 +312,10 @@ func callLogrus(m, t string) { logrus.Info(m) case "warning": logrus.Warning(m) - case "error": - logrus.Error(m) case "fatal": logrus.Error(m) + case "error": + logrus.Error(m) panic(m) default: logrus.Error(m) diff --git a/lib/mzn/mzn.go b/lib/mzn/mzn.go index a4415d60..76ff300f 100644 --- a/lib/mzn/mzn.go +++ b/lib/mzn/mzn.go @@ -125,7 +125,7 @@ func (p *MsData) ReadRaw(fileName, f string) { siVal1, e := strconv.ParseFloat(parts[5], 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } else { spec.Precursor.SelectedIon = siVal1 spec.Precursor.TargetIon = siVal1 @@ -133,7 +133,7 @@ func (p *MsData) ReadRaw(fileName, f string) { siVal2, e := strconv.ParseFloat(parts[6], 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } else { //spec.Precursor.SelectedIonIntensity = siVal2 spec.Precursor.TargetIonIntensity = siVal2 @@ -181,7 +181,7 @@ func (p *MsData) ReadRaw(fileName, f string) { } if len(spectra) == 0 { - msg.NoSpectraFound(errors.New(""), "fatal") + msg.NoSpectraFound(errors.New(""), "error") } p.Spectra = spectra @@ -213,7 +213,7 @@ func (p *MsData) Read(f string) { } if len(spectra) == 0 { - msg.NoSpectraFound(errors.New(""), "fatal") + msg.NoSpectraFound(errors.New(""), "error") } p.Spectra = spectra @@ -245,7 +245,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000016" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "error") + msg.CastFloatToString(e, "fatal") } spec.ScanStartTime = val } @@ -270,7 +270,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000827" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.TargetIon = val } @@ -278,7 +278,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000828" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.IsolationWindowLowerOffset = val } @@ -286,7 +286,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000829" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.IsolationWindowUpperOffset = val } @@ -297,7 +297,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000744" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.SelectedIon = val } @@ -305,7 +305,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000041" { val, e := strconv.Atoi(j.Value) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.ChargeState = val } @@ -313,7 +313,7 @@ func processSpectrum(mzSpec psi.Spectrum) Spectrum { if string(j.Accession) == "MS:1000042" { val, e := strconv.ParseFloat(j.Value, 64) if e != nil { - msg.CastFloatToString(e, "fatal") + msg.CastFloatToString(e, "error") } spec.Precursor.SelectedIonIntensity = val } @@ -401,7 +401,7 @@ func readEncoded(bin []byte, precision, isCompressed string) []float64 { if isCompressed == "1" { r, e := zlib.NewReader(b64) if e != nil { - msg.ReadingMzMLZlib(e, "error") + msg.ReadingMzMLZlib(e, "fatal") var emptyArray []float64 emptyArray = append(emptyArray, 0.0) return emptyArray diff --git a/lib/obo/obo.go b/lib/obo/obo.go index 8018cd36..04abca29 100644 --- a/lib/obo/obo.go +++ b/lib/obo/obo.go @@ -93,7 +93,7 @@ func (m *Onto) Parse() { file, e := os.Open(m.OboFile) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer file.Close() diff --git a/lib/pip/pip.go b/lib/pip/pip.go index f703fc20..d5e8e3d7 100644 --- a/lib/pip/pip.go +++ b/lib/pip/pip.go @@ -83,12 +83,12 @@ func DeployParameterFile(temp string) string { param, e := Asset("philosopher.yml") if e != nil { - msg.DeployAsset(errors.New("pipeline configuration file"), "fatal") + msg.DeployAsset(errors.New("pipeline configuration file"), "error") } e = ioutil.WriteFile(file, param, sys.FilePermission()) if e != nil { - msg.DeployAsset(errors.New("pipeline configuration file"), "fatal") + msg.DeployAsset(errors.New("pipeline configuration file"), "error") } return file @@ -145,7 +145,6 @@ func AnnotateDatabase(meta met.Data, p Directives, dir string, data []string) me os.Chdir(dir) for i := 1; i < len(data); i++ { - //source := fmt.Sprintf("%s%s.meta%sdb.bin", data[0], string(filepath.Separator), string(filepath.Separator)) destination := fmt.Sprintf("%s%s.meta%sdb.bin", data[i], string(filepath.Separator), string(filepath.Separator)) // Read all content of src to data @@ -159,7 +158,6 @@ func AnnotateDatabase(meta met.Data, p Directives, dir string, data []string) me log.Fatal(e) } - //meta.Serialize() } met.CleanTemp(meta.Temp) @@ -172,10 +170,6 @@ func DBSearch(meta met.Data, p Directives, dir string, data []string) met.Data { logrus.Info("Running the Database Search") - // if meta.Pipeline.Verbose == true { - // p.DatabaseSearch.MSFragger.ToCmdString() - // } - // reload the meta data meta.Restore(sys.Meta()) @@ -193,7 +187,7 @@ func DBSearch(meta met.Data, p Directives, dir string, data []string) met.Data { gobExtC := fmt.Sprintf("*.%s", p.DatabaseSearch.Comet.RawExtension) filesC, e := filepath.Glob(gobExtC) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } if len(filesC) > 0 { @@ -226,7 +220,7 @@ func DBSearch(meta met.Data, p Directives, dir string, data []string) met.Data { gobExtM := fmt.Sprintf("*.%s", p.DatabaseSearch.MSFragger.Extension) filesM, e := filepath.Glob(gobExtM) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } if len(filesM) > 0 { @@ -278,7 +272,7 @@ func PeptideProphet(meta met.Data, p Directives, dir string, data []string) met. gobExt := fmt.Sprintf("*.%s", p.PeptideProphet.FileExtension) files, e := filepath.Glob(gobExt) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } peptideprophet.Run(meta, files) @@ -326,7 +320,7 @@ func PeptideProphet(meta met.Data, p Directives, dir string, data []string) met. files, e := filepath.Glob(gobExt) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } peptideprophet.Run(meta, files) @@ -521,9 +515,6 @@ func CombinedProteinList(meta met.Data, p Directives, dir string, data []string) if _, err := os.Stat(path.Dir(proBin)); err == nil { os.RemoveAll(path.Dir(proBin)) - // if e != nil { - // log.Fatal(e) - // } } return meta diff --git a/lib/psi/psi.go b/lib/psi/psi.go index b91d1ae3..e91d6a04 100644 --- a/lib/psi/psi.go +++ b/lib/psi/psi.go @@ -100,7 +100,7 @@ func (p *IndexedMzML) Parse(f string) { xmlFile, e := os.Open(f) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer xmlFile.Close() b, _ := ioutil.ReadAll(xmlFile) @@ -112,7 +112,7 @@ func (p *IndexedMzML) Parse(f string) { decoder.CharsetReader = charset.NewReader if e = decoder.Decode(&mzml); e != nil { - msg.DecodeMsgPck(e, "fatal") + msg.DecodeMsgPck(e, "error") } p.MzML = mzml.MzML @@ -125,7 +125,7 @@ func (p *MzIdentML) Parse(f string) { xmlFile, e := os.Open(f) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer xmlFile.Close() @@ -148,7 +148,7 @@ func (p *MzIdentML) Write() { file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer file.Close() diff --git a/lib/qua/bqt.go b/lib/qua/bqt.go index bc988200..e659b150 100644 --- a/lib/qua/bqt.go +++ b/lib/qua/bqt.go @@ -74,18 +74,18 @@ func parseClusterFile(cls, database string) List { f, e := os.Open(cls) if e != nil { - msg.Custom(errors.New("cannot open cluster file"), "fatal") + msg.Custom(errors.New("cannot open cluster file"), "error") } defer f.Close() reheader, e1 := regexp.Compile(`^>Cluster\s+(.*)`) if e1 != nil { - msg.Custom(errors.New("cannot compile Cluster header regex"), "fatal") + msg.Custom(errors.New("cannot compile Cluster header regex"), "error") } reseq, e2 := regexp.Compile(`\|(.*)\|.*`) if e2 != nil { - msg.Custom(errors.New("cannot compile Cluster description regex"), "fatal") + msg.Custom(errors.New("cannot compile Cluster description regex"), "error") } scanner := bufio.NewScanner(f) @@ -98,7 +98,7 @@ func parseClusterFile(cls, database string) List { num := cluster[1] i, e := strconv.Atoi(num) if e != nil { - msg.Custom(errors.New("FASTA header not found"), "fatal") + msg.Custom(errors.New("FASTA header not found"), "error") } clusterNumber = i @@ -111,7 +111,7 @@ func parseClusterFile(cls, database string) List { centroid := strings.Split(scanner.Text(), "|") //centroid := reseq.FindStringSubmatch(scanner.Text()) if len(centroid) < 2 { - msg.Custom(errors.New("FASTA file contains non-formatted sequence headers"), "fatal") + msg.Custom(errors.New("FASTA file contains non-formatted sequence headers"), "error") } centroidmap[clusterNumber] = centroid[1] @@ -262,28 +262,28 @@ func getFile(getAll bool, resultDir string, organism string) (faMap map[string][ // tries to create an output file output, e := os.Create(outfile) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer output.Close() // Tries to query data from Uniprot response, e := http.Get(query) if e != nil { - msg.Custom(errors.New("could not find the annotation file"), "fatal") + msg.Custom(errors.New("could not find the annotation file"), "error") } defer response.Body.Close() // Tries to download data from Uniprot _, e = io.Copy(output, response.Body) if e != nil { - msg.Custom(errors.New("cannot download the annotation file"), "fatal") + msg.Custom(errors.New("cannot download the annotation file"), "error") } faMap = make(map[string][]string) f, e := os.Open(outfile) if outfile == "" || e != nil { - msg.Custom(errors.New("emty or inexisting file"), "fatal") + msg.Custom(errors.New("emty or inexisting file"), "error") } defer f.Close() @@ -305,7 +305,7 @@ func savetoDisk(list List, temp, uid string) { // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer file.Close() @@ -351,7 +351,7 @@ func savetoDisk(list List, temp, uid string) { _, e = io.WriteString(file, header) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } var faMap = make(map[string][]string) @@ -420,7 +420,7 @@ func savetoDisk(list List, temp, uid string) { _, e := io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } diff --git a/lib/qua/lfq.go b/lib/qua/lfq.go index f2c797eb..375dd8b8 100644 --- a/lib/qua/lfq.go +++ b/lib/qua/lfq.go @@ -226,7 +226,7 @@ func calculateIntensities(e rep.Evidence) rep.Evidence { logrus.Info("Assigning intensities to data layers") if len(e.PSM) < 1 || len(e.Ions) < 1 { - msg.QuantifyingData(errors.New("the PSM list is enpty"), "fatal") + msg.QuantifyingData(errors.New("the PSM list is enpty"), "error") } var peptideIntMap = make(map[string]float64) diff --git a/lib/qua/qua.go b/lib/qua/qua.go index b718f2b1..bc661846 100644 --- a/lib/qua/qua.go +++ b/lib/qua/qua.go @@ -60,7 +60,7 @@ func RunIsobaricLabelQuantification(p met.Quantify, mods bool) met.Quantify { var sourceList []string if p.Brand == "" { - msg.NoParametersFound(errors.New("you need to specify a brand type (tmt or itraq)"), "fatal") + msg.NoParametersFound(errors.New("you need to specify a brand type (tmt or itraq)"), "error") } var evi rep.Evidence @@ -637,7 +637,7 @@ func classification(evi rep.Evidence, mods, best bool, remove, purity, probabili } if remove != 0 && !quantCheckUp { - msg.NoParametersFound(errors.New("no reporter ions found. Check your MS level, or update msconvert"), "fatal") + msg.NoParametersFound(errors.New("no reporter ions found. Check your MS level, or update msconvert"), "error") } // 2nd check: best PSM diff --git a/lib/qua/spc.go b/lib/qua/spc.go index 12171c28..ff61031d 100644 --- a/lib/qua/spc.go +++ b/lib/qua/spc.go @@ -64,50 +64,3 @@ func CalculateSpectralCounts(e rep.Evidence) rep.Evidence { return e } - -// func CalculateSpectralCounts(e rep.Evidence) rep.Evidence { - -// var uniqueIonPSM = make(map[string]string) -// var razorIonPSM = make(map[string]string) - -// var sequences = make(map[string]int) - -// for _, i := range e.PSM { - -// sequences[i.Peptide]++ - -// if i.IsUnique { -// uniqueIonPSM[i.SpectrumFileName()] = i.ProteinID -// } -// if i.IsURazor { -// razorIonPSM[i.SpectrumFileName()] = i.ProteinID -// } -// } - -// for i := range e.Peptides { -// v, ok := sequences[e.Peptides[i].Sequence] -// if ok { -// e.Peptides[i].Spc += v -// } -// } - -// for i := range e.Proteins { - -// for _, j := range e.Proteins[i].TotalPeptideIons { - -// e.Proteins[i].TotalSpC += len(j.Spectra) - -// if j.IsUnique { -// e.Proteins[i].UniqueSpC += len(j.Spectra) -// } - -// if j.IsURazor { -// e.Proteins[i].URazorSpC += len(j.Spectra) -// } - -// } - -// } - -// return e -// } diff --git a/lib/rep/ion.go b/lib/rep/ion.go index 0f3db31f..cdb5d57e 100644 --- a/lib/rep/ion.go +++ b/lib/rep/ion.go @@ -118,7 +118,7 @@ func (evi IonEvidenceList) IonReport(workspace, brand, decoyTag string, channels file, e := os.Create(output) bw := bufio.NewWriter(file) if e != nil { - msg.WriteFile(errors.New("peptide ion output file"), "fatal") + msg.WriteFile(errors.New("peptide ion output file"), "error") } defer file.Close() defer bw.Flush() @@ -292,7 +292,7 @@ func (evi IonEvidenceList) IonReport(workspace, brand, decoyTag string, channels _, e = io.WriteString(bw, header) if e != nil { - msg.WriteToFile(errors.New("cannot print Ion to file"), "fatal") + msg.WriteToFile(errors.New("cannot print Ion to file"), "error") } for _, i := range printSet { @@ -487,7 +487,7 @@ func (evi IonEvidenceList) IonReport(workspace, brand, decoyTag string, channels _, e = io.WriteString(bw, line) if e != nil { - msg.WriteToFile(errors.New("cannot print Ions to file"), "fatal") + msg.WriteToFile(errors.New("cannot print Ions to file"), "error") } } diff --git a/lib/rep/modification.go b/lib/rep/modification.go index 5d5cd300..1be7c0b3 100644 --- a/lib/rep/modification.go +++ b/lib/rep/modification.go @@ -214,7 +214,7 @@ func (evi *Evidence) ModificationReport(workspace string, hasPrefix bool) { // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(errors.New("could not create report files"), "error") + msg.WriteFile(errors.New("could not create report files"), "fatal") } defer file.Close() @@ -222,7 +222,7 @@ func (evi *Evidence) ModificationReport(workspace string, hasPrefix bool) { _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } for _, i := range evi.Modifications.MassBins { @@ -236,7 +236,7 @@ func (evi *Evidence) ModificationReport(workspace string, hasPrefix bool) { line += "\n" _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } @@ -249,7 +249,7 @@ func (evi *Evidence) PlotMassHist() { file, e := os.Create(outfile) if e != nil { - msg.WriteFile(errors.New("could not create output for delta mass binning"), "fatal") + msg.WriteFile(errors.New("could not create output for delta mass binning"), "error") } defer file.Close() @@ -297,7 +297,7 @@ func (evi *Evidence) PlotMassHist() { io.WriteString(file, "") if e != nil { - msg.Custom(errors.New("there was an error trying to plot the mass distribution"), "fatal") + msg.Custom(errors.New("there was an error trying to plot the mass distribution"), "error") } // copy to work directory diff --git a/lib/rep/msstats.go b/lib/rep/msstats.go index 9eab7f20..7e3c48d2 100644 --- a/lib/rep/msstats.go +++ b/lib/rep/msstats.go @@ -32,7 +32,7 @@ func (evi Evidence) MetaMSstatsReport(workspace, brand string, channels int, has // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(errors.New("cannot create MSstats report"), "error") + msg.WriteFile(errors.New("cannot create MSstats report"), "fatal") } defer file.Close() @@ -82,7 +82,7 @@ func (evi Evidence) MetaMSstatsReport(workspace, brand string, channels int, has _, e = io.WriteString(file, header) if e != nil { - msg.WriteToFile(errors.New("cannot print PSM to file"), "fatal") + msg.WriteToFile(errors.New("cannot print PSM to file"), "error") } for _, i := range printSet { @@ -252,7 +252,7 @@ func (evi Evidence) MetaMSstatsReport(workspace, brand string, channels int, has _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(errors.New("cannot write to MSstats report"), "fatal") + msg.WriteToFile(errors.New("cannot write to MSstats report"), "error") } } } diff --git a/lib/rep/peptide.go b/lib/rep/peptide.go index e97a9b3e..c1471db6 100644 --- a/lib/rep/peptide.go +++ b/lib/rep/peptide.go @@ -147,7 +147,7 @@ func (evi PeptideEvidenceList) PeptideReport(workspace, brand, decoyTag string, file, e := os.Create(output) bw := bufio.NewWriter(file) if e != nil { - msg.WriteFile(errors.New("peptide output file"), "fatal") + msg.WriteFile(errors.New("peptide output file"), "error") } defer file.Close() defer bw.Flush() @@ -319,7 +319,7 @@ func (evi PeptideEvidenceList) PeptideReport(workspace, brand, decoyTag string, //_, e = io.WriteString(file, header) _, e = io.WriteString(bw, header) if e != nil { - msg.WriteToFile(errors.New("cannot print PSM to file"), "fatal") + msg.WriteToFile(errors.New("cannot print PSM to file"), "error") } for _, i := range printSet { @@ -516,7 +516,7 @@ func (evi PeptideEvidenceList) PeptideReport(workspace, brand, decoyTag string, _, e = io.WriteString(bw, line) if e != nil { - msg.WriteToFile(errors.New("cannot print Peptides to file"), "fatal") + msg.WriteToFile(errors.New("cannot print Peptides to file"), "error") } } } diff --git a/lib/rep/protein.go b/lib/rep/protein.go index bd39b84c..d0d2858b 100644 --- a/lib/rep/protein.go +++ b/lib/rep/protein.go @@ -174,7 +174,7 @@ func (evi *Evidence) AssembleProteinReport(pro id.ProtIDList, weight float64, de dtb.Restore() if len(dtb.Records) < 1 { - msg.DatabaseNotFound(errors.New(""), "fatal") + msg.DatabaseNotFound(errors.New(""), "error") } // fix the name sand headers and pull database information into protein report @@ -257,7 +257,7 @@ func (eviProteins ProteinEvidenceList) ProteinReport(workspace, brand, decoyTag file, e := os.Create(output) bw := bufio.NewWriter(file) if e != nil { - msg.WriteFile(errors.New("cannot create protein report"), "error") + msg.WriteFile(errors.New("cannot create protein report"), "fatal") } defer file.Close() defer bw.Flush() @@ -427,7 +427,7 @@ func (eviProteins ProteinEvidenceList) ProteinReport(workspace, brand, decoyTag _, e = io.WriteString(bw, header) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } for _, i := range printSet { @@ -664,7 +664,7 @@ func (eviProteins ProteinEvidenceList) ProteinReport(workspace, brand, decoyTag _, e = io.WriteString(bw, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } @@ -678,7 +678,7 @@ func (eviProteins ProteinEvidenceList) ProteinFastaReport(workspace string, hasD file, e := os.Create(output) bw := bufio.NewWriter(file) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer file.Close() defer bw.Flush() @@ -699,7 +699,7 @@ func (eviProteins ProteinEvidenceList) ProteinFastaReport(workspace string, hasD line := ">" + header + "\n" + i.Sequence + "\n" _, e = io.WriteString(bw, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } } diff --git a/lib/rep/psm.go b/lib/rep/psm.go index 38c3c0b0..f1560b97 100644 --- a/lib/rep/psm.go +++ b/lib/rep/psm.go @@ -72,7 +72,7 @@ func (evi *Evidence) AssemblePSMReport(pep id.PepIDList, decoyTag string) { p.IonMobility = i.IonMobility p.CompensationVoltage = i.CompensationVoltage p.MappedGenes = make(map[string]struct{}) - p.MappedProteins = make(map[string]int) + p.MappedProteins = make(map[string]string) p.Modifications = i.Modifications p.MSFraggerLoc = i.MSFragerLoc if i.UncalibratedPrecursorNeutralMass > 0 { @@ -88,9 +88,9 @@ func (evi *Evidence) AssemblePSMReport(pep id.PepIDList, decoyTag string) { p.ModifiedPeptide = "" } - for j := range i.AlternativeProteins { + for j, k := range i.AlternativeProteins { if !strings.Contains(j, decoyTag) { - p.MappedProteins[j]++ + p.MappedProteins[j] = k } } @@ -159,7 +159,7 @@ func (evi PSMEvidenceList) PSMReport(workspace, brand, decoyTag string, channels file, e := os.Create(output) bw := bufio.NewWriter(file) if e != nil { - msg.WriteFile(errors.New("cannot create report file, "+e.Error()), "fatal") + msg.WriteFile(errors.New("cannot create report file, "+e.Error()), "error") } defer file.Close() defer bw.Flush() @@ -424,7 +424,7 @@ func (evi PSMEvidenceList) PSMReport(workspace, brand, decoyTag string, channels _, e = io.WriteString(bw, header) if e != nil { - msg.WriteToFile(errors.New("cannot print PSM to file"), "fatal") + msg.WriteToFile(errors.New("cannot print PSM to file"), "error") } for _, i := range printSet { @@ -726,7 +726,7 @@ func (evi PSMEvidenceList) PSMReport(workspace, brand, decoyTag string, channels _, e = io.WriteString(bw, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } } @@ -739,13 +739,13 @@ func (evi *Evidence) PSMLocalizationReport(workspace, decoyTag string, hasRazor, // create result file file, e := os.Create(output) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer file.Close() _, e = io.WriteString(file, "Spectrum\tPeptide\tModified Peptide\tCharge\tRetention\tModification\tNumber of Sites\tObserved Mass Localization\n") if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } // building the printing set tat may or not contain decoys @@ -774,7 +774,7 @@ func (evi *Evidence) PSMLocalizationReport(workspace, decoyTag string, hasRazor, ) _, e = io.WriteString(file, line) if e != nil { - msg.WriteToFile(e, "fatal") + msg.WriteToFile(e, "error") } } } diff --git a/lib/rep/rep.go b/lib/rep/rep.go index 46cc1345..128a49a3 100644 --- a/lib/rep/rep.go +++ b/lib/rep/rep.go @@ -160,7 +160,7 @@ type PSMEvidence struct { MSFraggerLoc *id.MSFraggerLoc Labels *iso.Labels Modifications mod.ModificationsSlice - MappedProteins map[string]int + MappedProteins map[string]string MappedGenes map[string]struct{} } diff --git a/lib/rep/updater.go b/lib/rep/updater.go index 677f3dfa..03548bd7 100644 --- a/lib/rep/updater.go +++ b/lib/rep/updater.go @@ -90,9 +90,17 @@ func (evi *Evidence) UpdateIonStatus(decoyTag string) { // decoy by the target but it was removed because in some cases the protein // does not pass the FDR filtering. - evi.PSM[i].MappedProteins[evi.PSM[i].Protein] = 0 + evi.PSM[i].MappedProteins[evi.PSM[i].Protein] = evi.PSM[i].PrevAA + "#" + evi.PSM[i].NextAA + + // recover prevAA-nextAA + altPrt := evi.PSM[i].MappedProteins[rp] + prevNext := strings.Split(altPrt, "#") + delete(evi.PSM[i].MappedProteins, rp) + evi.PSM[i].Protein = rp + evi.PSM[i].PrevAA = prevNext[0] + evi.PSM[i].PrevAA = prevNext[1] } if !evi.PSM[i].IsURazor { @@ -106,9 +114,17 @@ func (evi *Evidence) UpdateIonStatus(decoyTag string) { // decoy by the target but it was removed because in some cases the protein // does not pass the FDR filtering. - evi.PSM[i].MappedProteins[evi.PSM[i].Protein] = 0 + evi.PSM[i].MappedProteins[evi.PSM[i].Protein] = evi.PSM[i].PrevAA + "#" + evi.PSM[i].NextAA + + // recover prevAA-nextAA + altPrt := evi.PSM[i].MappedProteins[sp] + prevNext := strings.Split(altPrt, "#") + delete(evi.PSM[i].MappedProteins, sp) + evi.PSM[i].Protein = sp + evi.PSM[i].PrevAA = prevNext[0] + evi.PSM[i].PrevAA = prevNext[1] if strings.Contains(sp, decoyTag) { evi.PSM[i].IsDecoy = true @@ -749,10 +765,22 @@ func (evi *Evidence) ApplyRazorAssignment() { evi.PSM[i].IsURazor = true - evi.PSM[i].MappedProteins[evi.PSM[i].Protein]++ + evi.PSM[i].MappedProteins[evi.PSM[i].Protein] = evi.PSM[i].PrevAA + "#" + evi.PSM[i].NextAA + + // TODO recover prev-next + altPrt := evi.PSM[i].MappedProteins[v.MappedProtein] + prevNext := strings.Split(altPrt, "#") + delete(evi.PSM[i].MappedProteins, v.MappedProtein) + evi.PSM[i].Protein = v.MappedProtein + // to avoid decoys + if len(prevNext) > 1 { + evi.PSM[i].PrevAA = prevNext[0] + evi.PSM[i].NextAA = prevNext[1] + } + } } } diff --git a/lib/spc/spc.go b/lib/spc/spc.go index 85d2b085..85e2d21d 100644 --- a/lib/spc/spc.go +++ b/lib/spc/spc.go @@ -58,7 +58,7 @@ func (p *PepXML) Parse(f string) { xmlFile, e := os.Open(f) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } reader := bufio.NewReader(xmlFile) decoder := xml.NewDecoder(reader) @@ -66,7 +66,7 @@ func (p *PepXML) Parse(f string) { var mpa MsmsPipelineAnalysis if e = decoder.Decode(&mpa); e != nil { - msg.DecodeMsgPck(e, "fatal") + msg.DecodeMsgPck(e, "error") } err := xmlFile.Close() if err != nil { @@ -83,7 +83,7 @@ func (p *ProtXML) Parse(f string) { xmlFile, e := os.Open(f) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer xmlFile.Close() @@ -94,7 +94,7 @@ func (p *ProtXML) Parse(f string) { decoder.CharsetReader = charset.NewReader if e = decoder.Decode(&ps); e != nil { - msg.DecodeMsgPck(e, "fatal") + msg.DecodeMsgPck(e, "error") } p.ProteinSummary = ps diff --git a/lib/sys/sys.go b/lib/sys/sys.go index 1e580b29..c2421789 100644 --- a/lib/sys/sys.go +++ b/lib/sys/sys.go @@ -4,7 +4,6 @@ import ( "bufio" "errors" "fmt" - "github.com/vmihailenco/msgpack/v5" "io" "os" "os/exec" @@ -12,6 +11,8 @@ import ( "runtime" "strings" + "github.com/vmihailenco/msgpack/v5" + "philosopher/lib/msg" ) @@ -28,7 +29,7 @@ func GetHome() string { } else if runtime.GOOS == Linux() { home = os.Getenv("HOME") } else { - msg.Custom(errors.New("cannot define your operating system"), "fatal") + msg.Custom(errors.New("cannot define your operating system"), "error") } return home @@ -43,7 +44,7 @@ func GetTemp() string { } else if runtime.GOOS == Linux() { tmp = "/tmp" } else { - msg.Custom(errors.New("cannot define your operating system"), "fatal") + msg.Custom(errors.New("cannot define your operating system"), "error") } return tmp @@ -53,7 +54,7 @@ func GetTemp() string { func VerifyTemp(f string) { if _, err := os.Stat(f); os.IsNotExist(err) { - msg.Custom(errors.New("cannot find the custom temporary folder"), "fatal") + msg.Custom(errors.New("cannot find the custom temporary folder"), "error") } } @@ -91,27 +92,27 @@ func CopyFile(from, to string) { // Open original file originalFile, e := os.Open(from) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer originalFile.Close() // Create new file newFile, e := os.Create(to) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") } defer newFile.Close() // Copy the bytes to destination from source _, e = io.Copy(newFile, originalFile) if e != nil { - msg.CopyingFile(e, "fatal") + msg.CopyingFile(e, "error") } // Commit the file contents e = newFile.Sync() if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } } @@ -235,7 +236,7 @@ func FilePermission() os.FileMode { func Serialize(v interface{}, filename string) { output, e := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, FilePermission()) if e != nil { - msg.WriteFile(e, "fatal") + msg.WriteFile(e, "error") panic(e) } bo := bufio.NewWriter(output) @@ -244,12 +245,12 @@ func Serialize(v interface{}, filename string) { err := enc.Encode(&v) errFlush := bo.Flush() if errFlush != nil { - msg.MarshalFile(errFlush, "fatal") + msg.MarshalFile(errFlush, "error") panic(errFlush) } _ = output.Close() if err != nil { - msg.MarshalFile(err, "fatal") + msg.MarshalFile(err, "error") panic(err) } } @@ -260,7 +261,7 @@ func Restore(v interface{}, filename string, silent bool) { return } if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") panic(e) } bi := bufio.NewReader(input) @@ -272,7 +273,7 @@ func Restore(v interface{}, filename string, silent bool) { panic(errClose) } if err != nil && !silent { - msg.DecodeMsgPck(err, "fatal") + msg.DecodeMsgPck(err, "error") panic(err) } } diff --git a/lib/trq/trq.go b/lib/trq/trq.go index 7053ceeb..19072d0b 100644 --- a/lib/trq/trq.go +++ b/lib/trq/trq.go @@ -44,7 +44,7 @@ func New(plex string) iso.Labels { o.Channel8.Mz = 121.1220 } else { - msg.Custom(errors.New("unknown multiplex setting, please define the plex number used in your experiment"), "error") + msg.Custom(errors.New("unknown multiplex setting, please define the plex number used in your experiment"), "fatal") } return o diff --git a/lib/uti/uti.go b/lib/uti/uti.go index 6173f9a8..8ec48274 100644 --- a/lib/uti/uti.go +++ b/lib/uti/uti.go @@ -87,7 +87,7 @@ func GetLabelNames(annot string) map[string]string { file, e := os.Open(annot) if e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } defer file.Close() @@ -96,19 +96,13 @@ func GetLabelNames(annot string) map[string]string { // does the line has at least an iso tag? if len(scanner.Text()) >= 3 { - // replace tabs and multiple spaces by single space - // space := regexp.MustCompile(`\s+`) - // line := space.ReplaceAllString(scanner.Text(), " ") - - // names := strings.Split(line, " ") - names := strings.Fields(scanner.Text()) labels[names[0]] = names[1] } } if e = scanner.Err(); e != nil { - msg.ReadFile(e, "fatal") + msg.ReadFile(e, "error") } return labels diff --git a/lib/wrk/unix.go b/lib/wrk/unix.go index 69024db4..e92ae6db 100644 --- a/lib/wrk/unix.go +++ b/lib/wrk/unix.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package wrk @@ -16,7 +17,7 @@ func HideFile(filename string) { if !strings.HasPrefix(filepath.Base(filename), ".") { e := os.Rename(filename, "."+filename) if e != nil { - msg.Custom(errors.New("cannot hide file"), "error") + msg.Custom(errors.New("cannot hide file"), "fatal") } } } diff --git a/lib/wrk/win.go b/lib/wrk/win.go index 669c23b0..d36e29fd 100644 --- a/lib/wrk/win.go +++ b/lib/wrk/win.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package wrk @@ -13,11 +14,11 @@ import ( func HideFile(filename string) { filenameW, e := syscall.UTF16PtrFromString(filename) if e != nil { - msg.Custom(e, "fatal") + msg.Custom(e, "error") } e = syscall.SetFileAttributes(filenameW, syscall.FILE_ATTRIBUTE_HIDDEN) if e != nil { - msg.Custom(errors.New("Cannot hide file"), "error") + msg.Custom(errors.New("Cannot hide file"), "fatal") } return } diff --git a/lib/wrk/wrk.go b/lib/wrk/wrk.go index e0ac62d9..5e1a2d79 100644 --- a/lib/wrk/wrk.go +++ b/lib/wrk/wrk.go @@ -27,7 +27,7 @@ func Run(Version, Build, temp string, backup, clean, initialize, nocheck bool) { } if (initialize && backup && clean) || (initialize && backup) || (initialize && clean) || (clean && backup) { - msg.Custom(errors.New("this command accepts only one parameter"), "fatal") + msg.Custom(errors.New("this command accepts only one parameter"), "error") } if initialize { @@ -79,7 +79,7 @@ func Init(version, build, temp string) { os.Mkdir(da.MetaDir, sys.FilePermission()) if _, e := os.Stat(sys.MetaDir()); os.IsNotExist(e) { - msg.CreatingMetaDirectory(e, "fatal") + msg.CreatingMetaDirectory(e, "error") } if runtime.GOOS == sys.Windows() { @@ -88,7 +88,7 @@ func Init(version, build, temp string) { os.Mkdir(da.Temp, sys.FilePermission()) if _, e := os.Stat(da.Temp); os.IsNotExist(e) { - msg.LocatingTemDirecotry(e, "fatal") + msg.LocatingTemDirecotry(e, "error") } da.Serialize() @@ -107,7 +107,7 @@ func Backup() { } if len(m.UUID) < 1 && len(m.Home) < 1 { - msg.LocatingMetaDirecotry(errors.New(""), "error") + msg.LocatingMetaDirecotry(errors.New(""), "fatal") } var name string @@ -125,7 +125,7 @@ func Backup() { e = zip.ArchiveFile(sys.MetaDir(), outFilePath, progress) if e != nil { - msg.ArchivingMetaDirecotry(e, "error") + msg.ArchivingMetaDirecotry(e, "fatal") } } diff --git a/philosopher.yml b/philosopher.yml index 9ce4b921..356543dd 100644 --- a/philosopher.yml +++ b/philosopher.yml @@ -57,7 +57,7 @@ Database Search: # MSFragger-3.5 & Comet v201901 calibrate_mass: 2 # 0=Off, 1=On, 2=On and find optimal parameters use_all_mods_in_first_search: 0 # use all variable modifications in first search (0 for No, 1 for Yes). write_calibrated_mgf: 0 # write calibrated MS2 scan to a MGF file (0 for No, 1 for Yes) - isotope_error: 0/1/2 # 0=off, 0/1/2 (standard C13 error) + isotope_error: 0/1/2 # 0=off, 0/1/2 (standard C13 "error") mass_offsets: 0 # allow for additional precursor mass window shifts. Multiplexed with isotope_error. mass_offsets = 0/79.966 can be used as a restricted ‘open’ search that looks for unmodified and phosphorylated peptides (on any residue) restrict_deltamass_to: all # specify amino acids on which delta masses (mass offsets or search modifications) can occur. Allowed values are single letter codes (e.g. ACD), must precursor_mass_mode: selected # one of isolated/selected/corrected.