Skip to content
Snippets Groups Projects
Commit 8b522570 authored by tjc's avatar tjc
Browse files

store sample data as an array

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15163 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 9cc478de
No related branches found
No related tags found
No related merge requests found
......@@ -187,22 +187,28 @@ class BCFReader
nc = 1;
String fmts[] = bcfRecord.format.split(":");
for(int j=0; j<fmts.length; j++)
bcfRecord.data = new String[nsamples][fmts.length];
for(int j=0; j<nsamples; j++)
{
for(int k=0; k<fmts.length; k++)
{
int nb = getByteSize(fmts[j],nc);
int nb = getByteSize(fmts[k],nc);
str = new byte[nb];
is.read(str);
final String value;
if(fmts[j].equals("GT"))
if(fmts[k].equals("GT"))
value = getGTString(str[0]);
else if(fmts[j].equals("PL"))
else if(fmts[k].equals("PL"))
value = getPLString(str, nc);
else if(fmts[j].equals("DP")||fmts[j].equals("SP")||fmts[j].equals("GQ"))
else if(fmts[k].equals("DP")||fmts[k].equals("SP")||fmts[k].equals("GQ"))
value = Integer.toString(byteToInt(str[0]));
else
value = "";
bcfRecord.data.put(fmts[j], value);
bcfRecord.data[j][k] = value;
}
}
}
......
......@@ -23,9 +23,6 @@
package uk.ac.sanger.artemis.components.variant;
import java.util.HashMap;
import java.util.Iterator;
class VCFRecord
{
protected String ID;
......@@ -37,14 +34,32 @@ class VCFRecord
protected float quality;
protected String info;
protected String format;
protected HashMap<String, String> data = new HashMap<String, String>();
protected String data[][];
public String toString()
{
return seqID+"\t"+pos+"\t"+ID+"\t"+ref+"\t"+alt+"\t"+quality+
"\t"+filter+"\t"+info+"\t"+format+"\t"+getSampleDataString();
}
/**
* Return the sample data as a tab-delimited string
* @return
*/
private String getSampleDataString()
{
StringBuffer buff = new StringBuffer();
Iterator<String> it = data.values().iterator();
while(it.hasNext())
buff.append(it.next()+ ( (it.hasNext()) ? ":" : "" ) );
return seqID+"\t"+pos+"\t"+ID+"\t"+ref+"\t"+alt+"\t"+quality+"\t"+filter+"\t"+info+"\t"+format+"\t"+buff.toString();
for(int i=0; i<data.length; i++) // loop over samples
{
for(int j=0; j<data[i].length; j++) // loop over values
{
buff.append(data[i][j]);
if(j<data[i].length-1)
buff.append(":");
}
if(i<data.length-1)
buff.append("\t");
}
return buff.toString();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment