| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4fd3fdb commit d724aec
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -182,6 +182,10 @@ private String parse(BufferedReader bufferedReader) { | |||
| 182 | 182 | ||
| 183 | 183 | isCircularSequence = m.group(7).equalsIgnoreCase("circular"); | |
| 184 | 184 | ||
| 185 | + // configure location parser with needed information | ||
| 186 | + locationParser.setSequenceLength(sequenceLength); | ||
| 187 | + locationParser.setSequenceCircular(isCircularSequence); | ||
| 188 | + | ||
| 185 | 189 | log.debug("compound type: {}", compoundType.getClass().getSimpleName()); | |
| 186 | 190 | ||
| 187 | 191 | } else { | |
@@ -284,7 +288,7 @@ private String parse(BufferedReader bufferedReader) { | |||
| 284 | 288 | // new feature! | |
| 285 | 289 | gbFeature = new TextFeature(key, val, key, key); | |
| 286 | 290 | Location l = | |
| 287 | - locationParser.parse(val, isCircularSequence); | ||
| 291 | + locationParser.parse(val); | ||
| 288 | 292 | gbFeature.setLocation((AbstractLocation)l); | |
| 289 | 293 | ||
| 290 | 294 | if (!featureCollection.containsKey(key)) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ | |||
| 35 | 35 | import java.io.IOException; | |
| 36 | 36 | import java.io.Reader; | |
| 37 | 37 | import java.util.ArrayList; | |
| 38 | + import java.util.Arrays; | ||
| 38 | 39 | import java.util.List; | |
| 39 | 40 | import java.util.regex.Matcher; | |
| 40 | 41 | import java.util.regex.Pattern; | |
@@ -49,6 +50,9 @@ | |||
| 49 | 50 | */ | |
| 50 | 51 | public class InsdcParser <S extends AbstractSequence<C>, C extends Compound>{ | |
| 51 | 52 | ||
| 53 | + private boolean isSequenceCircular; | ||
| 54 | + private long sequenceLength; | ||
| 55 | + | ||
| 52 | 56 | private final DataSource dataSource; | |
| 53 | 57 | ||
| 54 | 58 | /** | |
@@ -80,7 +84,6 @@ public class InsdcParser <S extends AbstractSequence<C>, C extends Compound>{ | |||
| 80 | 84 | * Not really sure that they are not declared obsolete but they are still in | |
| 81 | 85 | * several files. | |
| 82 | 86 | */ | |
| 83 | - //protected static final Pattern genbankSplitPattern = Pattern.compile("^\\s?(join|order|bond|complement|)\\(?([^\\)]+)\\)?"); | ||
| 84 | 87 | protected static final Pattern genbankSplitPattern = Pattern.compile("^\\s?(join|order|bond|complement|)\\(?(.+)\\)?"); | |
| 85 | 88 | /** | |
| 86 | 89 | * designed to recursively split a location string in tokens. Valid tokens | |
@@ -126,7 +129,13 @@ public DataSource getDataSource() { | |||
| 126 | 129 | return dataSource; | |
| 127 | 130 | } | |
| 128 | 131 | ||
| 132 | + public void setSequenceCircular(boolean sequenceCircular) { | ||
| 133 | + isSequenceCircular = sequenceCircular; | ||
| 134 | + } | ||
| 129 | 135 | ||
| 136 | + public void setSequenceLength(long sequenceLength) { | ||
| 137 | + this.sequenceLength = sequenceLength; | ||
| 138 | + } | ||
| 130 | 139 | ||
| 131 | 140 | /** | |
| 132 | 141 | * Main method for parsing a location from a String instance | |
@@ -135,12 +144,12 @@ public DataSource getDataSource() { | |||
| 135 | 144 | * @return The parsed location | |
| 136 | 145 | * @throws ParserException thrown in the event of any error during parsing | |
| 137 | 146 | */ | |
| 138 | - public Location parse(String locationString, boolean isSequenceCircular) throws ParserException { | ||
| 147 | + public Location parse(String locationString) throws ParserException { | ||
| 139 | 148 | featureGlobalStart = Integer.MAX_VALUE; | |
| 140 | 149 | featureGlobalEnd = 1; | |
| 141 | 150 | ||
| 142 | 151 | Location l; | |
| 143 | - List<Location> ll = parseLocationString(locationString, 1, isSequenceCircular); | ||
| 152 | + List<Location> ll = parseLocationString(locationString, 1); | ||
| 144 | 153 | ||
| 145 | 154 | if (ll.size() == 1) { | |
| 146 | 155 | l = ll.get(0); | |
@@ -155,10 +164,6 @@ public Location parse(String locationString, boolean isSequenceCircular) throws | |||
| 155 | 164 | return l; | |
| 156 | 165 | } | |
| 157 | 166 | ||
| 158 | - public Location parse(String locationString) throws ParserException { | ||
| 159 | - return parse(locationString, false); | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | 167 | /** | |
| 163 | 168 | * Reader based version of the parse methods. | |
| 164 | 169 | * | |
@@ -173,7 +178,7 @@ public List<AbstractLocation> parse(Reader reader) throws IOException, ParserExc | |||
| 173 | 178 | return null; | |
| 174 | 179 | } | |
| 175 | 180 | ||
| 176 | - private List<Location> parseLocationString(String string, int versus, boolean isSequenceCircular) throws ParserException { | ||
| 181 | + private List<Location> parseLocationString(String string, int versus) throws ParserException { | ||
| 177 | 182 | Matcher m; | |
| 178 | 183 | List<Location> boundedLocationsCollection = new ArrayList<Location>(); | |
| 179 | 184 | ||
@@ -192,7 +197,7 @@ private List<Location> parseLocationString(String string, int versus, boolean is | |||
| 192 | 197 | //recursive case | |
| 193 | 198 | int localVersus = splitQualifier.equalsIgnoreCase("complement") ? -1 : 1; | |
| 194 | 199 | List<Location> subLocations = parseLocationString( | |
| 195 | - splitString, versus * localVersus, isSequenceCircular); | ||
| 200 | + splitString, versus * localVersus); | ||
| 196 | 201 | ||
| 197 | 202 | switch (complexFeaturesAppendMode) { | |
| 198 | 203 | case FLATTEN: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments