Skip to content
Snippets Groups Projects
Commit 7e4add4d authored by tjc's avatar tjc
Browse files

read remote BCF files

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15678 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent ec49e183
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,9 @@ package uk.ac.sanger.artemis.components.variant; ...@@ -26,7 +26,9 @@ package uk.ac.sanger.artemis.components.variant;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.Writer; import java.io.Writer;
import java.net.URL;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
import java.util.regex.Pattern; import java.util.regex.Pattern;
...@@ -39,7 +41,7 @@ class BCFReader extends AbstractVCFReader ...@@ -39,7 +41,7 @@ class BCFReader extends AbstractVCFReader
public static final int TAD_LIDX_SHIFT = 13; // linear index shift public static final int TAD_LIDX_SHIFT = 13; // linear index shift
private static Pattern formatPattern = Pattern.compile("[^0-9]+"); private static Pattern formatPattern = Pattern.compile("[^0-9]+");
private BlockCompressedInputStream is; private BlockCompressedInputStream is;
private FileInputStream indexFileStream; private InputStream indexFileStream;
private List<BCFIndex> idx; private List<BCFIndex> idx;
// header information and names // header information and names
...@@ -50,18 +52,27 @@ class BCFReader extends AbstractVCFReader ...@@ -50,18 +52,27 @@ class BCFReader extends AbstractVCFReader
private String fileName; private String fileName;
/** /**
* @param bcf BCF file * @param bcf BCF file or url
* @throws IOException * @throws IOException
*/ */
public BCFReader(File bcf) throws IOException public BCFReader(String bcf) throws IOException
{ {
is = new BlockCompressedInputStream(bcf); if(bcf.startsWith("http"))
readHeader(); {
URL bcfURL = new URL(bcf);
File bcfIndex = new File(bcf.getAbsolutePath()+".bci"); is = new BlockCompressedInputStream(bcfURL);
indexFileStream = new FileInputStream(bcfIndex); indexFileStream = new URL(bcf+".bci").openStream();
fileName = bcfURL.getFile();
}
else
{
File bcfFile = new File(bcf);
is = new BlockCompressedInputStream(bcfFile);
indexFileStream = new FileInputStream(new File(bcf+".bci"));
fileName = bcfFile.getAbsolutePath();
}
idx = loadIndex(); idx = loadIndex();
fileName = bcf.getAbsolutePath(); readHeader();
} }
protected void seek(long off) throws IOException protected void seek(long off) throws IOException
...@@ -339,7 +350,7 @@ class BCFReader extends AbstractVCFReader ...@@ -339,7 +350,7 @@ class BCFReader extends AbstractVCFReader
protected static void writeVCF(Writer writer, String vcfFileName) throws IOException protected static void writeVCF(Writer writer, String vcfFileName) throws IOException
{ {
BCFReader reader = new BCFReader(new File(vcfFileName)); BCFReader reader = new BCFReader(vcfFileName);
writer.write( reader.headerToString()+"\n" ); writer.write( reader.headerToString()+"\n" );
int sbeg = 0; int sbeg = 0;
...@@ -486,7 +497,7 @@ class BCFReader extends AbstractVCFReader ...@@ -486,7 +497,7 @@ class BCFReader extends AbstractVCFReader
send = Integer.parseInt(rgn[1]); send = Integer.parseInt(rgn[1]);
} }
BCFReader reader = new BCFReader(new File(args[0])); BCFReader reader = new BCFReader(args[0]);
int bid = 0; int bid = 0;
if(chr != null) if(chr != null)
bid = reader.getSeqIndex(chr); bid = reader.getSeqIndex(chr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment