-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snip those raw files #732
Open
trishorts
wants to merge
30
commits into
smith-chem-wisc:master
Choose a base branch
from
trishorts:mzMLcleaner
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
snip those raw files #732
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
a6b1639
correct Within calculation
fa4da8b
update unit tests
3246567
conflicts resolved back to upstream
a018d4d
Merge remote-tracking branch 'upstream/master'
15a37d0
Merge remote-tracking branch 'upstream/master'
892fa45
this is the spot
211013c
Merge remote-tracking branch 'upstream/master'
68104ee
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts d715a08
Merge remote-tracking branch 'upstream/master'
3565522
Merge remote-tracking branch 'upstream/master'
72e7b53
Merge remote-tracking branch 'upstream/master'
593872a
Merge remote-tracking branch 'upstream/master'
trishorts 42dd034
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts fbeaec0
Merge remote-tracking branch 'upstream/master'
trishorts 614ded7
Merge remote-tracking branch 'upstream/master'
47307c8
Merge branch 'master' of https://github.com/trishorts/mzLib
28e05ae
Merge remote-tracking branch 'upstream/master'
0a7c609
Merge remote-tracking branch 'upstream/master'
630d8c7
Merge remote-tracking branch 'upstream/master'
trishorts f6a386b
Merge branch 'master' of https://github.com/trishorts/mzLib
trishorts d673800
Merge remote-tracking branch 'upstream/master'
675a0ae
Merge branch 'master' of https://github.com/trishorts/mzLib
15d4baf
Merge remote-tracking branch 'upstream/master'
03ca9f7
Merge remote-tracking branch 'upstream/master'
d0a4c79
Merge remote-tracking branch 'upstream/master'
894b998
Merge remote-tracking branch 'upstream/master'
88269a1
Merge remote-tracking branch 'upstream/master'
trishorts 9a9b24a
Merge remote-tracking branch 'upstream/master'
trishorts b4ad231
add space
trishorts b417087
snipper
trishorts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using MassSpectrometry; | ||
|
||
namespace Readers; | ||
|
||
public class SnipCreator | ||
{ | ||
public void Snipper(string origDataFile, int startScan, int endScan) | ||
{ | ||
|
||
FilteringParams filter = new FilteringParams(200, 0.01, 1, null, false, false, true); | ||
var reader = MsDataFileReader.GetDataFile(origDataFile); | ||
reader.LoadAllStaticData(filter, 1); | ||
|
||
var scans = reader.GetAllScansList(); | ||
var scansToKeep = scans.Where(x => x.OneBasedScanNumber >= startScan && x.OneBasedScanNumber <= endScan).ToList(); | ||
|
||
List<(int oneBasedScanNumber, int? oneBasedPrecursorScanNumber)> scanNumbers = new List<(int oneBasedScanNumber, int? oneBasedPrecursorScanNumber)>(); | ||
|
||
foreach (var scan in scansToKeep) | ||
{ | ||
if (scan.OneBasedPrecursorScanNumber.HasValue && (scan.OneBasedPrecursorScanNumber.Value - startScan + 1) >= 0) | ||
{ | ||
scanNumbers.Add((scan.OneBasedScanNumber, scan.OneBasedPrecursorScanNumber)); | ||
} | ||
} | ||
|
||
Dictionary<int, int> scanNumberMap = new Dictionary<int, int>(); | ||
|
||
foreach (var scanNumber in scanNumbers) | ||
{ | ||
if (!scanNumberMap.ContainsKey(scanNumber.oneBasedScanNumber)) | ||
{ | ||
scanNumberMap.Add(scanNumber.oneBasedScanNumber, scanNumber.oneBasedScanNumber - startScan + 1); | ||
} | ||
if (scanNumber.oneBasedPrecursorScanNumber.HasValue && !scanNumberMap.ContainsKey(scanNumber.oneBasedPrecursorScanNumber.Value)) | ||
{ | ||
scanNumberMap.Add(scanNumber.oneBasedPrecursorScanNumber.Value, scanNumber.oneBasedPrecursorScanNumber.Value - startScan + 1); | ||
} | ||
} | ||
List<MsDataScan> scansForTheNewFile = new List<MsDataScan>(); | ||
|
||
|
||
foreach (var scanNumber in scanNumbers) | ||
{ | ||
MsDataScan scan = scansToKeep.First(x => x.OneBasedScanNumber == scanNumber.oneBasedScanNumber); | ||
|
||
MsDataScan newDataScan = new MsDataScan( | ||
scan.MassSpectrum, | ||
scanNumberMap[scan.OneBasedScanNumber], | ||
scan.MsnOrder, | ||
scan.IsCentroid, | ||
scan.Polarity, | ||
scan.RetentionTime, | ||
scan.ScanWindowRange, | ||
scan.ScanFilter, | ||
scan.MzAnalyzer, | ||
scan.TotalIonCurrent, | ||
scan.InjectionTime, | ||
scan.NoiseData, | ||
scan.NativeId.Replace(scan.OneBasedPrecursorScanNumber.ToString(), scanNumberMap[scan.OneBasedScanNumber].ToString()), | ||
scan.SelectedIonMZ, | ||
scan.SelectedIonChargeStateGuess, | ||
scan.SelectedIonIntensity, | ||
scan.IsolationMz, | ||
scan.IsolationWidth, | ||
scan.DissociationType, | ||
scanNumberMap[scan.OneBasedPrecursorScanNumber.Value], | ||
scan.SelectedIonMonoisotopicGuessMz, | ||
scan.HcdEnergy | ||
); | ||
scansForTheNewFile.Add(newDataScan); | ||
} | ||
|
||
string outPath = origDataFile.Replace(".mzML", "_snip.mzML"); | ||
|
||
SourceFile sourceFile = new SourceFile(reader.SourceFile.NativeIdFormat, | ||
reader.SourceFile.MassSpectrometerFileFormat, reader.SourceFile.CheckSum, reader.SourceFile.Uri.ToString(), | ||
reader.SourceFile.FileName); | ||
|
||
MzmlMethods.CreateAndWriteMyMzmlWithCalibratedSpectra(new GenericMsDataFile(scansForTheNewFile.ToArray(),sourceFile), outPath, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this test implement the class you wrote above?