Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QcmpCompressionLibrary
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
QcmpCompressionLibrary
Commits
b078632e
Commit
b078632e
authored
4 years ago
by
Vojtech Moravec
Browse files
Options
Downloads
Patches
Plain Diff
Improved the CalculateDifference custom function.
parent
e79d3f27
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/cz/it4i/qcmp/cli/functions/CalculateDifference.java
+76
-0
76 additions, 0 deletions
.../java/cz/it4i/qcmp/cli/functions/CalculateDifference.java
with
76 additions
and
0 deletions
src/main/java/cz/it4i/qcmp/cli/functions/CalculateDifference.java
0 → 100644
+
76
−
0
View file @
b078632e
package
cz.it4i.qcmp.cli.functions
;
import
cz.it4i.qcmp.cli.CompressionOptionsCLIParser
;
import
cz.it4i.qcmp.cli.CustomFunctionBase
;
import
cz.it4i.qcmp.io.RawDataIO
;
import
cz.it4i.qcmp.io.loader.PlaneLoaderFactory
;
import
cz.it4i.qcmp.utilities.TypeConverter
;
import
cz.it4i.qcmp.utilities.Utils
;
import
org.apache.commons.io.FileUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Collection
;
public
class
CalculateDifference
extends
CustomFunctionBase
{
/**
* Base constructor with parsed CLI options.
*
* @param options Parsed cli options.
*/
public
CalculateDifference
(
final
CompressionOptionsCLIParser
options
)
{
super
(
options
);
}
@Override
public
boolean
run
()
{
assert
(
options
.
getInputDataInfo
().
isPlaneIndexSet
());
final
int
planeIndex
=
options
.
getInputDataInfo
().
getPlaneIndex
();
final
String
directory
=
options
.
getOutputFilePath
();
final
int
[]
referenceData
;
try
{
referenceData
=
PlaneLoaderFactory
.
getPlaneLoaderForInputFile
(
options
.
getInputDataInfo
()).
loadPlaneData
(
planeIndex
);
}
catch
(
final
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
final
Collection
<
File
>
rawFiles
=
FileUtils
.
listFiles
(
new
File
(
directory
),
new
String
[]{
"raw"
},
false
);
// final Collection<File> rawFiles = Arrays.asList(new File("gc_vq3x3_8b_670.raw"),
// new File("mpc_vq3x3_8b_670.raw"),
// new File("ic_vq3x3_8b_670.raw"));
for
(
final
File
file
:
rawFiles
)
{
final
String
absoluteDiffResultFile
=
file
.
getAbsolutePath
().
replace
(
".raw"
,
"_adiff.raw"
);
final
String
diffResultFile
=
file
.
getAbsolutePath
().
replace
(
".raw"
,
"_diff.raw"
);
final
int
[]
fileData
;
try
{
final
byte
[]
fileBytes
=
FileUtils
.
readFileToByteArray
(
file
);
fileData
=
TypeConverter
.
unsignedShortBytesToIntArray
(
fileBytes
);
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
final
int
[]
diffData
=
Utils
.
getDifference
(
referenceData
,
fileData
);
try
{
RawDataIO
.
writeDataI32
(
diffResultFile
,
diffData
,
true
);
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
Utils
.
applyAbsFunction
(
diffData
);
final
byte
[]
resultBytes
=
TypeConverter
.
unsignedShortArrayToByteArray
(
diffData
,
true
);
try
{
FileUtils
.
writeByteArrayToFile
(
new
File
(
absoluteDiffResultFile
),
resultBytes
);
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
System
.
out
.
println
(
"Finished: "
+
diffResultFile
);
}
return
true
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment