Skip to content
Snippets Groups Projects
Commit 9cc478de authored by tjc's avatar tjc
Browse files

assign contents of VCFRecord in getParts()

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15162 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 583fc312
Branches
Tags
No related merge requests found
...@@ -178,18 +178,10 @@ class BCFReader ...@@ -178,18 +178,10 @@ class BCFReader
byte[] str = new byte[slen]; byte[] str = new byte[slen];
is.read(str); is.read(str);
String parts[] = getParts(str); getParts(str, bcfRecord);
bcfRecord.ID = parts[0]; if(formatPattern.matcher(bcfRecord.format).matches())
bcfRecord.ref = parts[1];
bcfRecord.alt = parts[2];
String fmt = parts[parts.length-1];
if(formatPattern.matcher(fmt).matches())
{ {
bcfRecord.info = parts[parts.length-2];
bcfRecord.format = parts[parts.length-1];
int nc = 3; int nc = 3;
if(bcfRecord.alt.equals(".")) if(bcfRecord.alt.equals("."))
nc = 1; nc = 1;
...@@ -214,40 +206,50 @@ class BCFReader ...@@ -214,40 +206,50 @@ class BCFReader
} }
} }
else
bcfRecord.info = parts[parts.length-1];
return bcfRecord; return bcfRecord;
} }
/** /**
* Make a string from the byte array. Expanding NULL padding. * Make a string from the byte array (expanding NULL padding) to
* determine the parts:- ID+REF+ALT+FILTER+INFO+FORMAT.
* @param b * @param b
* @return * @return
*/ */
private String[] getParts(byte[] b) private void getParts(byte[] b, VCFRecord bcfRecord)
{ {
StringBuffer buff = new StringBuffer(); StringBuffer buff = new StringBuffer();
for(int i=0; i<b.length; i++) for(int i=0; i<b.length; i++)
{ {
if(i == 0 && b[i] == 0) if(b[i] == 0)
{
if(i == 0)
{ {
buff.append(". "); buff.append(". ");
continue; continue;
} }
if(b[i] == 0) if(b[i-1] == 0 || (i < b.length-1 && b[i+1] == 0))
{ {
if(i > 0 && b[i-1] == 0 && b[i+1] == 0) i++;
buff.append(" . "); buff.append(" . ");
}
else else
buff.append(" "); buff.append(" ");
continue;
} }
else
buff.append((char)b[i]); buff.append((char)b[i]);
} }
return buff.toString().split(" "); String parts[] = buff.toString().replace(" ", " ").split(" ");
bcfRecord.ID = parts[0];
bcfRecord.ref = parts[1];
bcfRecord.alt = parts[2];
bcfRecord.filter = parts[3];
bcfRecord.info = parts[4];
bcfRecord.format = parts[5];
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment