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

optimise split() functions

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@15581 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 99954024
Branches
Tags
No related merge requests found
......@@ -46,7 +46,8 @@ class VCFRecord
private String data[][];
private short synFlag = -1;
protected static Pattern MULTI_ALLELE_PATTERN = Pattern.compile("^[AGCT]+,[AGCT,]+$");
protected static Pattern COLON_PATTERN = Pattern.compile(":");
protected static Pattern SEMICOLON_PATTERN = Pattern.compile(";");
/**
* Return the string representation of the VCF record as a
......@@ -96,13 +97,15 @@ class VCFRecord
rec.data = new String[nsamples][nfmt];
for(int i=0; i<nsamples; i++)
{
String data[] = parts[9+i].split(":");
String data[] = COLON_PATTERN.split(parts[9+i]);
rec.data[i] = data;
}
}
return rec;
}
/**
* For example DP or MQ
* @param key
......@@ -110,7 +113,7 @@ class VCFRecord
*/
protected String getInfoValue(String key)
{
String parts[] = info.split(";");
String parts[] = SEMICOLON_PATTERN.split(info);
for(int i=0; i<parts.length; i++)
if(parts[i].startsWith(key+"="))
return parts[i].substring(key.length()+1);
......@@ -119,7 +122,7 @@ class VCFRecord
protected String getFormatValue(String key)
{
String fmts[] = getFormat().split(":");
String fmts[] = COLON_PATTERN.split(getFormat());
for(int i=0; i<fmts.length; i++)
{
if(fmts[i].equals(key))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment