High-performance interval list implement -- uses StringBuilder to avoid n^2 calculation. Can handle millions of locations quickly now
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@182 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
30babbf5b9
commit
ff98e28abf
|
|
@ -187,7 +187,7 @@ public class TraversalEngine {
|
||||||
* @param file_name
|
* @param file_name
|
||||||
*/
|
*/
|
||||||
public void setLocationFromFile(final String file_name) {
|
public void setLocationFromFile(final String file_name) {
|
||||||
String locStr = "";
|
StringBuilder locStr = new StringBuilder();
|
||||||
|
|
||||||
Scanner scanner = null;
|
Scanner scanner = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -195,9 +195,9 @@ public class TraversalEngine {
|
||||||
while (scanner.hasNextLine()) {
|
while (scanner.hasNextLine()) {
|
||||||
String line = scanner.nextLine();
|
String line = scanner.nextLine();
|
||||||
line.replaceAll("\n", "");
|
line.replaceAll("\n", "");
|
||||||
locStr += line;
|
locStr.append(line);
|
||||||
if (scanner.hasNextLine()) {
|
if (scanner.hasNextLine()) {
|
||||||
locStr += ";";
|
locStr.append(";");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,9 +210,9 @@ public class TraversalEngine {
|
||||||
scanner.close();
|
scanner.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("DEBUG: locStr: " + locStr);
|
logger.debug("DEBUG: locStr: " + locStr.toString());
|
||||||
|
|
||||||
this.locs = parseGenomeLocs(locStr);
|
this.locs = parseGenomeLocs(locStr.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class GenomeLoc implements Comparable<GenomeLoc> {
|
||||||
|
|
||||||
public static GenomeLoc parseGenomeLoc( final String str ) {
|
public static GenomeLoc parseGenomeLoc( final String str ) {
|
||||||
// Ôchr2Õ, Ôchr2:1000000Õ or Ôchr2:1,000,000-2,000,000Õ
|
// Ôchr2Õ, Ôchr2:1000000Õ or Ôchr2:1,000,000-2,000,000Õ
|
||||||
System.out.printf("Parsing location '%s'%n", str);
|
//System.out.printf("Parsing location '%s'%n", str);
|
||||||
|
|
||||||
final Pattern regex1 = Pattern.compile("([\\w&&[^:]]+)$"); // matches case 1
|
final Pattern regex1 = Pattern.compile("([\\w&&[^:]]+)$"); // matches case 1
|
||||||
final Pattern regex2 = Pattern.compile("([\\w&&[^:]]+):([\\d,]+)$"); // matches case 2
|
final Pattern regex2 = Pattern.compile("([\\w&&[^:]]+):([\\d,]+)$"); // matches case 2
|
||||||
|
|
@ -102,7 +102,7 @@ public class GenomeLoc implements Comparable<GenomeLoc> {
|
||||||
}
|
}
|
||||||
|
|
||||||
GenomeLoc loc = new GenomeLoc(contig, start, stop);
|
GenomeLoc loc = new GenomeLoc(contig, start, stop);
|
||||||
System.out.printf(" => Parsed location '%s' into %s%n", str, loc);
|
//System.out.printf(" => Parsed location '%s' into %s%n", str, loc);
|
||||||
|
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue