Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/loci/formats/S3FileSystemStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.bc.zarr.ZarrUtils;
import com.bc.zarr.storage.Store;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
Expand Down Expand Up @@ -88,8 +87,8 @@ public String getRoot() {
}

private void setupClient() {
String[] pathSplit = root.toString().split(File.separator);
String endpoint = ENDPOINT_PROTOCOL + pathSplit[1] + File.separator;
String[] pathSplit = root.toString().split("/");
String endpoint = ENDPOINT_PROTOCOL + pathSplit[1] + "/";
try {
client = AmazonS3ClientBuilder.standard()
.withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(endpoint, "auto"))
Expand All @@ -115,11 +114,11 @@ public S3FileSystemStore(Path rootPath) {
@Override
public InputStream getInputStream(String key) throws IOException {
// Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point
String[] pathSplit = root.toString().split(File.separator);
String[] pathSplit = root.toString().split("/");
String bucketName = pathSplit[2];

// Append the desired key onto the remaining prefix
String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()) + File.separator + key;
String key2 = root.toString().substring(root.toString().indexOf(pathSplit[3]), root.toString().length()) + "/" + key;

try {
S3Object o = client.getObject(bucketName, key2);
Expand Down Expand Up @@ -201,7 +200,7 @@ private TreeSet<String> getKeysFor(String suffix) throws IOException {
TreeSet<String> keys = new TreeSet<String>();

// Get the base bucket name from splitting the root path and removing the prefixed protocol and end-point
String[] pathSplit = root.toString().split(File.separator);
String[] pathSplit = root.toString().split("/");
String bucketName = pathSplit[2];

// Append the desired key onto the remaining prefix
Expand Down
17 changes: 3 additions & 14 deletions src/loci/formats/in/ZarrReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public class ZarrReader extends FormatReader {
private boolean planesPrePopulated = false;
private boolean hasSPW = false;
private transient int currentOpenZarr = -1;
private String zarrRootPath;

public ZarrReader() {
super("Zarr", "zarr");
Expand Down Expand Up @@ -181,8 +182,7 @@ protected void initFile(String id) throws FormatException, IOException {
final MetadataStore store = makeFilterMetadata();
Location zarrFolder = new Location(id);
String zarrPath = zarrFolder.getAbsolutePath();
String zarrRootPath = zarrPath.substring(0, zarrPath.indexOf(".zarr") + 5);
String name = zarrRootPath.substring(zarrRootPath.lastIndexOf(File.separator)+1, zarrRootPath.length() - 5);
this.zarrRootPath = zarrPath.substring(0, zarrPath.indexOf(".zarr") + 5);
Location omeMetaFile = new Location( zarrRootPath + File.separator + "OME", "METADATA.ome.xml" );
String canonicalPath = new Location(zarrRootPath).getCanonicalPath();

Expand Down Expand Up @@ -456,7 +456,6 @@ private static int[] getOriginalShape(int [] shape5D, int size) {
@Override
public void reopenFile() throws IOException {
try {
String canonicalPath = new Location(currentId).getCanonicalPath();
initializeZarrService();
}
catch (FormatException e) {
Expand All @@ -465,7 +464,7 @@ public void reopenFile() throws IOException {
}

protected void initializeZarrService() throws IOException, FormatException {
zarrService = new JZarrServiceImpl(altStore());
zarrService = new JZarrServiceImpl(zarrRootPath);
openZarr();
}

Expand Down Expand Up @@ -779,16 +778,6 @@ private void parsePlate(Map<String, Object> attr, String root, String key, Metad
}
}

// TODO: Likely remove as values unused
// for (int c = 0; c < columns.size(); c++) {
// Map<String, Object> column = (Map<String, Object>) columns.get(c);
// String colName = (String) column.get("name");
// }
// for (int r = 0; r < rows.size(); r++) {
// Map<String, Object> row = (Map<String, Object>) rows.get(r);
// String rowName = (String) row.get("name");
// }

//Create empty wells for each row and column
wellCount = rows.size() * columns.size();
for (int r = 0; r < rows.size(); r++) {
Expand Down
15 changes: 2 additions & 13 deletions src/loci/formats/services/JZarrServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,9 @@
*/

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteOrder;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;

import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -80,14 +75,8 @@ public class JZarrServiceImpl extends AbstractService
*/
public JZarrServiceImpl(String root) {
checkClassDependency(com.bc.zarr.ZarrArray.class);
if (root != null && (root.toLowerCase().contains("s3:") || root.toLowerCase().contains("s3."))) {
String[] pathSplit = root.toString().split(File.separator);
if (S3FileSystemStore.ENDPOINT_PROTOCOL.contains(pathSplit[0].toLowerCase())) {
if (root != null && (root.matches("^https?:.*") || root.matches("^s3:.*"))) {
s3fs = new S3FileSystemStore(Paths.get(root));
}
else {
LOGGER.warn("Zarr Reader is not using S3FileSystemStore as this is currently for use with S3 configured with a https endpoint");
}
}
}

Expand Down
1 change: 0 additions & 1 deletion src/loci/formats/services/ZarrService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import loci.common.services.Service;
import loci.formats.FormatException;
import loci.formats.meta.MetadataRetrieve;
import loci.formats.services.ZarrService.Compression;

public interface ZarrService extends Service {

Expand Down
2 changes: 1 addition & 1 deletion test/loci/formats/utests/JZarrServiceImplTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.loci.formats.utests;
package loci.formats.utests;

/*-
* #%L
Expand Down
2 changes: 1 addition & 1 deletion test/loci/formats/utests/ZarrReaderMock.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.loci.formats.utests;
package loci.formats.utests;

/*-
* #%L
Expand Down
2 changes: 1 addition & 1 deletion test/loci/formats/utests/ZarrReaderTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package test.loci.formats.utests;
package loci.formats.utests;

/*-
* #%L
Expand Down
Loading