Source:
public static List<Site> parseSites(File f) throws IOException { InputStream inStream = new FileInputStream(f); InputStream gzipStream = new GZIPInputStream(inStream); Reader decoder = new InputStreamReader(gzipStream); BufferedReader buf = new BufferedReader(decoder); String line = null; List<Site > data = new ArrayList<Site>(); List<String> headerFields = null; int proteinIndex = -1; int uniprotIndex = -1; int residueIndex = -1; int orgIndex = -1; int groupIndex = -1; int geneIndex = -1; boolean inHeader = true; while ((line = buf.readLine()) != null){ if ( line.startsWith("GENE")) { headerFields = parseHeaderFields(line); proteinIndex = headerFields.indexOf("PROTEIN"); uniprotIndex = headerFields.indexOf("ACC_ID"); residueIndex = headerFields.indexOf("MOD_RSD"); orgIndex = headerFields.indexOf("ORGANISM"); groupIndex = headerFields.indexOf("SITE_GRP_ID"); geneIndex = headerFields.indexOf("GENE"); inHeader = false; continue; } if ( inHeader) continue; if ( line.trim().length() == 0) continue; String[] spl = line.split("\t"); if ( spl.length < 5){ logger.info("Found wrong line length: " + line); continue; } String protein = spl[proteinIndex]; String uniprot = spl[uniprotIndex]; String residue = spl[residueIndex]; String[] resSpl = residue.split("-"); String modType = null; if ( resSpl.length == 2) { modType = resSpl[1]; } String group = spl[groupIndex]; String organism = spl[orgIndex]; String geneSymb = spl[geneIndex]; Site s = new Site(); s.setProtein(protein); s.setUniprot(uniprot); s.setGeneSymb(geneSymb); s.setModType(modType); s.setResidue(residue); s.setGroup(group); s.setOrganism(organism); data.add(s); } buf.close(); return data; }

Target:
public static List<Site> parseSites(File f) throws IOException { InputStream inStream = new FileInputStream(f); InputStream gzipStream = new GZIPInputStream(inStream); Reader decoder = new InputStreamReader(gzipStream); BufferedReader buf = new BufferedReader(decoder); String line = null; List<Site > data = new ArrayList<Site>(); List<String> headerFields = null; int proteinIndex = -1; int uniprotIndex = -1; int residueIndex = -1; int orgIndex = -1; int groupIndex = -1; int geneIndex = -1; boolean inHeader = true; while ((line = buf.readLine()) != null){ if ( line.startsWith("GENE") || line.startsWith("PROTEIN")) { headerFields = parseHeaderFields(line); proteinIndex = headerFields.indexOf("PROTEIN"); uniprotIndex = headerFields.indexOf("ACC_ID"); residueIndex = headerFields.indexOf("MOD_RSD"); orgIndex = headerFields.indexOf("ORGANISM"); groupIndex = headerFields.indexOf("SITE_GRP_ID"); geneIndex = headerFields.indexOf("GENE"); inHeader = false; continue; } if ( inHeader) continue; if ( line.trim().length() == 0) continue; String[] spl = line.split("\t"); if ( spl.length < 5){ logger.info("Found wrong line length: " + line); continue; } String protein = spl[proteinIndex]; String uniprot = spl[uniprotIndex]; String residue = spl[residueIndex]; String[] resSpl = residue.split("-"); String modType = null; if ( resSpl.length == 2) { modType = resSpl[1]; } String group = spl[groupIndex]; String organism = spl[orgIndex]; String geneSymb = spl[geneIndex]; Site s = new Site(); s.setProtein(protein); s.setUniprot(uniprot); s.setGeneSymb(geneSymb); s.setModType(modType); s.setResidue(residue); s.setGroup(group); s.setOrganism(organism); data.add(s); } buf.close(); return data; }