diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f97022 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/resource.iml b/resource.iml new file mode 100644 index 0000000..3f52f0d --- /dev/null +++ b/resource.iml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/panda/resource/UniProtSequence.java b/src/main/java/org/panda/resource/UniProtSequence.java index 726d172..f66604d 100644 --- a/src/main/java/org/panda/resource/UniProtSequence.java +++ b/src/main/java/org/panda/resource/UniProtSequence.java @@ -5,6 +5,7 @@ package org.panda.resource; + import java.io.BufferedReader; import java.io.IOException; import java.util.HashMap; @@ -129,6 +130,19 @@ public String getSeqAround(String idOrName, int prefixLen, int suffixLen, int lo */ int max = ((prefixLen > suffixLen ? prefixLen : suffixLen) * 2) + 1; + + +// max/2 is how many you want to left/right of central position + // if you want k to the right, and you are at the kth position or lesser, this is impossible + if(max/2 >= location){ + return null; + } + + /* + The call to getSeqAround takes the width as an argument. Consider, if the width/2 = k, + then there will be k amino acids to the left and to the right. + */ + // Will take an odd-length as argument, and return sequence of that length // centered around location @@ -189,7 +203,11 @@ public boolean load() throws IOException { this.nameToID.put(name, id); sequence = new StringBuilder(); int oInd = line.indexOf(" OX="); - String organism = line.substring(oInd + 4, line.indexOf(" ", oInd + 4)); + + + String organism = line. substring(oInd + 4, line.indexOf(" ", oInd + 4)); + + int sInd = line.indexOf(" GN="); if (sInd > 0) { String symbol = line.substring(sInd + 4, line.indexOf(" ", sInd + 4)); @@ -202,9 +220,11 @@ public boolean load() throws IOException { } } else { sequence.append(line); + } } + reader.close(); return true; }