-
Notifications
You must be signed in to change notification settings - Fork 18
preserve input star columns during particle export #433
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
Changes from all commits
2068f79
0614f93
becc4d9
31e0981
188c709
464eb5e
5daf02a
6c51516
e19a6f4
14784f0
fe284ab
a899a0b
ad096b2
8ace542
6c25a35
e96199a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,8 @@ class ExportParticlesTiltseriesOptions : DistributedOptions | |
|
|
||
| class ExportParticlesTiltseries : BaseCommand | ||
| { | ||
| private Dictionary<string, string[]> _additionalColumns; | ||
|
|
||
| public override async Task Run(object options) | ||
| { | ||
| await base.Run(options); | ||
|
|
@@ -167,6 +169,26 @@ public override async Task Run(object options) | |
| } | ||
|
|
||
| ValidateInputStar(inputStar); | ||
| _additionalColumns = new Dictionary<string, string[]>(); | ||
| var knownColumns = new HashSet<string> | ||
| { | ||
| "rlnCoordinateX", "rlnCoordinateY", "rlnCoordinateZ", | ||
| "rlnMicrographName", "rlnTomoName", | ||
| "rlnOriginX", "rlnOriginXAngst", | ||
| "rlnOriginY", "rlnOriginYAngst", | ||
| "rlnOriginZ", "rlnOriginZAngst", | ||
| "rlnPixelSize", "rlnImagePixelSize", | ||
| "rlnAngleRot", "rlnAngleTilt", "rlnAnglePsi", | ||
| "rlnOpticsGroup", "rlnOpticsGroupName" | ||
| }; | ||
| foreach (var columnName in inputStar.GetColumnNames()) | ||
| { | ||
| if (!knownColumns.Contains(columnName)) | ||
| { | ||
| _additionalColumns.Add(columnName, inputStar.GetColumn(columnName)); | ||
| } | ||
| } | ||
|
Comment on lines
+172
to
+190
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reserved-column filter is incomplete.
🤖 Prompt for AI Agents |
||
|
|
||
| string[] tiltSeriesIDs = inputStar.HasColumn("rlnMicrographName") ? inputStar.GetColumn("rlnMicrographName") : inputStar.GetColumn("rlnTomoName"); | ||
| Dictionary<string, List<int>> tiltSeriesIdToParticleIndices = | ||
| GroupParticles(tiltSeriesIDs); | ||
|
|
@@ -236,6 +258,21 @@ public override async Task Run(object options) | |
| float3[] tsParticleXyzAngstroms = new float3[tsParticleIdx.Count]; | ||
| float3[] tsParticleRotTiltPsi = new float3[tsParticleIdx.Count]; | ||
|
|
||
| Dictionary<string, string[]> tsAdditionalColumns = new Dictionary<string, string[]>(); | ||
| if (_additionalColumns.Count > 0) | ||
| { | ||
| foreach (var col in _additionalColumns) | ||
| { | ||
| var colData = new string[tsParticleIdx.Count]; | ||
| for (int i = 0; i < tsParticleIdx.Count; i++) | ||
| { | ||
| colData[i] = col.Value[tsParticleIdx[i]]; | ||
| } | ||
| tsAdditionalColumns.Add(col.Key, colData); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| if (Helper.IsDebug) | ||
| Console.WriteLine($"{tsParticleIdx.Count} particles for {tiltSeries.Name}"); | ||
|
|
||
|
|
@@ -279,7 +316,8 @@ public override async Task Run(object options) | |
| inputHasEulerAngles: inputHasEulerAngles, | ||
| outputPixelSize: cli.OutputPixelSize, | ||
| relativeToParticleStarFile: cli.OutputPathsRelativeToStarFile, | ||
| particleStarFile: cli.OutputStarFile); | ||
| particleStarFile: cli.OutputStarFile, | ||
| additionalColumns: tsAdditionalColumns); | ||
| lock (OutputStarTables) | ||
| OutputStarTables.Add(tiltSeries.Name, TiltSeriesTable); | ||
| } | ||
|
|
@@ -302,7 +340,8 @@ public override async Task Run(object options) | |
| pathTableOut: TempTiltSeriesParticleStarPath, | ||
| pathsRelativeTo: cli.OutputPathsRelativeToStarFile ? | ||
| Path.GetFullPath(OutputStarPath) : | ||
| Directory.GetCurrentDirectory()); | ||
| Directory.GetCurrentDirectory(), | ||
| additionalColumns: tsAdditionalColumns); | ||
|
|
||
| // generate necessary metadata for particles.star | ||
| if (Helper.IsDebug) | ||
|
|
@@ -697,7 +736,8 @@ private Star ConstructSubvolumeOutputTable( | |
| bool inputHasEulerAngles, | ||
| float outputPixelSize, | ||
| bool relativeToParticleStarFile, // default is relative to working directory | ||
| string? particleStarFile | ||
| string? particleStarFile, | ||
| Dictionary<string, string[]> additionalColumns | ||
| ) | ||
| { | ||
| int nParticles = xyz.Length; | ||
|
|
@@ -807,6 +847,14 @@ private Star ConstructSubvolumeOutputTable( | |
| table.RemoveColumn("rlnAnglePsi"); | ||
| } | ||
|
|
||
| if (additionalColumns != null) | ||
| { | ||
| foreach (var pair in additionalColumns) | ||
| { | ||
| table.AddColumn(pair.Key, pair.Value); | ||
| } | ||
| } | ||
|
|
||
| return table; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| using Microsoft.Extensions.Hosting; | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.IO; | ||
| using System.Linq; | ||
|
|
@@ -75,7 +76,7 @@ static async Task Main(string[] args) | |
| webBuilder.UseKestrel(options => | ||
| { | ||
| options.ListenAnyIP(Port); | ||
| options.Limits.MaxRequestBodySize = 104857600; // 100 MB | ||
| options.Limits.MaxRequestBodySize = 500 * 1024 * 1024; // 100 MB | ||
| }) | ||
|
Comment on lines
76
to
80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major This hardcoded body-size bump just moves the failure point. With 🤖 Prompt for AI Agents |
||
| .UseStartup<RESTStartup>() | ||
| .ConfigureLogging(logging => logging.SetMinimumLevel(LogLevel.Warning)); | ||
|
|
@@ -858,6 +859,19 @@ public static void EvaluateCommand(NamedSerializableObject Command) | |
|
|
||
| TiltSeries T = new TiltSeries(Path); | ||
| T.ReconstructParticleSeries(Options, Coordinates, Angles, PathsRelativeTo, out TableOut); | ||
|
|
||
| Dictionary<string, string[]> AdditionalColumns = null; | ||
| if (Command.Content.Length > 6) | ||
| AdditionalColumns = (Dictionary<string, string[]>)Command.Content[6]; | ||
|
|
||
| if (AdditionalColumns != null) | ||
| { | ||
| foreach (var col in AdditionalColumns) | ||
| { | ||
| TableOut.AddColumn(col.Key, col.Value); | ||
| } | ||
| } | ||
|
|
||
| T.SaveMeta(); | ||
|
|
||
| if (!string.IsNullOrEmpty(PathTableOut)) | ||
|
|
||
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.
Keep the original public overload.
Replacing
Warp.WorkerWrapper.TomoExportParticleSerieswith a 7-parameter signature is a source/binary break for existing consumers compiled against the old API. SinceWarpWorker.WarpWorkerProcess.EvaluateCommandalready treats the extra payload item as optional, keep the old overload and forward it to the new one instead of replacing it.💡 Suggested compatibility overload
📝 Committable suggestion
🤖 Prompt for AI Agents