- int slashPos = line.indexOf('/');
- if (slashPos == -1)
- {
- Cache.log.error("Unexpected EMBL line ignored: " + line);
- continue;
- }
- int eqPos = line.indexOf('=', slashPos + 1);
- if (eqPos == -1)
- {
- Cache.log.error("Unexpected EMBL line ignored: " + line);
- continue;
- }
- String qualifier = line.substring(slashPos + 1, eqPos);
- String value = line.substring(eqPos + 1);
- if (value.startsWith("\"") && value.endsWith("\""))
- {
- value = value.substring(1, value.length() - 1);
- }
-
- if ("protein_id".equals(qualifier))
- {
- proteinId = value;
- }
- else if ("codon_start".equals(qualifier))
- {
- try
- {
- codonStart = Integer.parseInt(value.trim());
- } catch (NumberFormatException e)
- {
- Cache.log.error("Invalid codon_start in XML for " + this.accession
- + ": " + e.getMessage());
- }
- }
- else if ("product".equals(qualifier))
- {
- // sometimes name is returned e.g. for V00488
- proteinName = value;
- }
- else if ("translation".equals(qualifier))
- {
- line = readTranslation(value);
- }
- else if (!"".equals(value))
- {
- // throw anything else into the additional properties hash
- cdsProps.put(qualifier, value);
- }
- }
-
- return line;
- }
-
- /**
- * Reads and saves the CDS translation from one or more lines of the file, and
- * returns the next line after that
- *
- * @param value
- * the first line of the translation (likely quoted)
- * @return
- * @throws IOException
- */
- String readTranslation(String value) throws IOException
- {
- StringBuilder sb = new StringBuilder(this.length / 3 + 1);
- sb.append(value.replace("\"", ""));
-
- String line;
- while ((line = nextLine()) != null)
- {
- if (!line.startsWith("FT "))
- {
- break; // reached next feature or other input line
- }
- String[] tokens = line.split(WHITESPACE);
- if (tokens.length < 2)
- {
- Cache.log.error("Ignoring bad EMBL line: " + line);
- break;
- }
- if (tokens[1].startsWith("/"))