+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
+ * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
package jalview.datamodel.xdb.embl;
import jalview.datamodel.DBRefEntry;
/**
* @param accession
- * the accession to set
+ * the accession to set
*/
public void setAccession(String accession)
{
/**
* @param dbRefs
- * the dbRefs to set
+ * the dbRefs to set
*/
public void setDbRefs(Vector dbRefs)
{
/**
* @param desc
- * the desc to set
+ * the desc to set
*/
public void setDesc(String desc)
{
/**
* @param features
- * the features to set
+ * the features to set
*/
public void setFeatures(Vector features)
{
/**
* @param keywords
- * the keywords to set
+ * the keywords to set
*/
public void setKeywords(Vector keywords)
{
/**
* @param lastUpdated
- * the lastUpdated to set
+ * the lastUpdated to set
*/
public void setLastUpdated(String lastUpdated)
{
/**
* @param refs
- * the refs to set
+ * the refs to set
*/
public void setRefs(Vector refs)
{
/**
* @param releaseCreated
- * the releaseCreated to set
+ * the releaseCreated to set
*/
public void setRcreated(String releaseCreated)
{
/**
* @param releaseLastUpdated
- * the releaseLastUpdated to set
+ * the releaseLastUpdated to set
*/
public void setRLastUpdated(String releaseLastUpdated)
{
/**
* @param sequence
- * the sequence to set
+ * the sequence to set
*/
public void setSequence(EmblSequence sequence)
{
/**
* @param taxDivision
- * the taxDivision to set
+ * the taxDivision to set
*/
public void setTaxDivision(String taxDivision)
{
/**
* @param version
- * the version to set
+ * the version to set
*/
public void setVersion(String version)
{
* Recover annotated sequences from EMBL file
*
* @param noNa
- * don't return nucleic acid sequences
+ * don't return nucleic acid sequences
* @param sourceDb
- * TODO
+ * TODO
* @param noProtein
- * don't return any translated protein sequences marked in features
+ * don't return any translated protein sequences marked in
+ * features
* @return dataset sequences with DBRefs and features - DNA always comes first
*/
public jalview.datamodel.SequenceI[] getSequences(boolean noNa,
boolean noPeptide, String sourceDb)
- { //TODO: ensure emblEntry.getSequences behaves correctly for returning all cases of noNa and noPeptide
+ { // TODO: ensure emblEntry.getSequences behaves correctly for returning all
+ // cases of noNa and noPeptide
Vector seqs = new Vector();
Sequence dna = null;
if (!noNa)
{
- // In theory we still need to create this if noNa is set to avoid a null pointer exception
+ // In theory we still need to create this if noNa is set to avoid a null
+ // pointer exception
dna = new Sequence(sourceDb + "|" + accession, sequence.getSequence());
dna.setDescription(desc);
dna.addDBRef(new DBRefEntry(sourceDb, version, accession));
// TODO: transform EMBL Database refs to canonical form
if (dbRefs != null)
for (Iterator i = dbRefs.iterator(); i.hasNext(); dna
- .addDBRef((DBRefEntry) i.next()))
- ;
+ .addDBRef((DBRefEntry) i.next()))
+ ;
}
try
{
}
}
}
- }
- catch (Exception e)
+ } catch (Exception e)
{
System.err.println("EMBL Record Features parsing error!");
System.err
}
/**
- * attempt to extract coding region and product from a feature and properly decorate it with annotations.
- * @param feature coding feature
- * @param sourceDb source database for the EMBLXML
- * @param seqs place where sequences go
- * @param dna parent dna sequence for this record
- * @param noPeptide flag for generation of Peptide sequence objects
+ * attempt to extract coding region and product from a feature and properly
+ * decorate it with annotations.
+ *
+ * @param feature
+ * coding feature
+ * @param sourceDb
+ * source database for the EMBLXML
+ * @param seqs
+ * place where sequences go
+ * @param dna
+ * parent dna sequence for this record
+ * @param noPeptide
+ * flag for generation of Peptide sequence objects
*/
- private void parseCodingFeature(EmblFeature feature, String sourceDb, Vector seqs, Sequence dna, boolean noPeptide)
+ private void parseCodingFeature(EmblFeature feature, String sourceDb,
+ Vector seqs, Sequence dna, boolean noPeptide)
{
boolean isEmblCdna = sourceDb.equals(DBRefSource.EMBLCDS);
// extract coding region(s)
else
{
// throw anything else into the additional properties hash
- String[] s= q.getValues();
+ String[] s = q.getValues();
StringBuffer sb = new StringBuffer();
- if (s!=null)
+ if (s != null)
{
- for (int i=0; i<s.length; i++)
+ for (int i = 0; i < s.length; i++)
{
sb.append(s[i]);
sb.append("\n");
if (prseq != null && prname != null && prid != null)
{
// extract proteins.
- product = new Sequence(prid
- , prseq, prstart, prstart
- + prseq.length() - 1);
- product.setDescription(((prname.length()==0) ? "Protein Product from " + sourceDb : prname));
-
+ product = new Sequence(prid, prseq, prstart, prstart + prseq.length()
+ - 1);
+ product
+ .setDescription(((prname.length() == 0) ? "Protein Product from "
+ + sourceDb
+ : prname));
+
if (!noPeptide)
{
// Protein is also added to vector of sequences returned
// marked.
exon = new int[]
{ dna.getStart(), dna.getEnd() };
- map = new jalview.datamodel.Mapping(product, exon,
- new int[]
- { prstart, prstart + prseq.length() - 1 }, 3, 1);
+ map = new jalview.datamodel.Mapping(product, exon, new int[]
+ { prstart, prstart + prseq.length() - 1 }, 3, 1);
}
if ((prseq.length() + 1) * 3 == dna.getSequence().length)
{
exon = new int[]
{ dna.getStart(), dna.getEnd() - 3 };
- map = new jalview.datamodel.Mapping(product, exon,
- new int[]
- { prstart, prstart + prseq.length() - 1 }, 3, 1);
+ map = new jalview.datamodel.Mapping(product, exon, new int[]
+ { prstart, prstart + prseq.length() - 1 }, 3, 1);
}
}
else
{
// TODO: Add a DbRef back to the parent EMBL sequence with the exon
// map
- // if given a dataset reference, search dataset for parent EMBL sequence if it exists and set its map
+ // if given a dataset reference, search dataset for parent EMBL
+ // sequence if it exists and set its map
// make a new feature annotating the coding contig
}
else
{
- map = new jalview.datamodel.Mapping(product, exon,
- new int[]
- { prstart, prstart + prseq.length() - 1 }, 3, 1);
+ map = new jalview.datamodel.Mapping(product, exon, new int[]
+ { prstart, prstart + prseq.length() - 1 }, 3, 1);
// reconstruct the EMBLCDS entry
DBRefEntry pcdnaref = new DBRefEntry();
pcdnaref.setAccessionId(prid);
pcdnaref.setSource(DBRefSource.EMBLCDS);
pcdnaref.setVersion(getVersion()); // same as parent EMBL version.
jalview.util.MapList mp = new jalview.util.MapList(new int[]
- { 1+(prstart-1)*3, 1+(prstart-1)*3 + (prseq.length()-1)*3 }, new int[] { prstart, prstart+prseq.length() - 1 }, 3, 1);
+ { 1 + (prstart - 1) * 3,
+ 1 + (prstart - 1) * 3 + (prseq.length() - 1) * 3 }, new int[]
+ { prstart, prstart + prseq.length() - 1 }, 3, 1);
pcdnaref.setMap(new Mapping(mp));
- if (product!=null)
+ if (product != null)
product.addDBRef(pcdnaref);
-
+
}
}
// add cds feature to dna seq - this may include the stop codon
sf.setEnd(exon[xint + 1]);
sf.setType(feature.getName());
sf.setFeatureGroup(sourceDb);
- sf.setDescription("Exon " + (1 + (int)(xint/2)) + " for protein '"
- + prname + "' EMBLCDS:" + prid);
+ sf.setDescription("Exon " + (1 + (int) (xint / 2))
+ + " for protein '" + prname + "' EMBLCDS:" + prid);
sf.setValue(FeatureProperties.EXONPOS, new Integer(1 + xint));
sf.setValue(FeatureProperties.EXONPRODUCT, prname);
if (vals != null && vals.size() > 0)
ref.setSource(jalview.util.DBRefUtils.getCanonicalName(ref
.getSource()));
// Hard code the kind of protein product accessions that EMBL cite
- if (ref.getSource().equals(
- jalview.datamodel.DBRefSource.UNIPROT))
+ if (ref.getSource().equals(jalview.datamodel.DBRefSource.UNIPROT))
{
ref.setMap(map);
- if (map!=null && map.getTo()!=null)
+ if (map != null && map.getTo() != null)
{
- map.getTo().addDBRef(new DBRefEntry(ref.getSource(), ref.getVersion(), ref.getAccessionId())); // don't copy map over.
- if (map.getTo().getName().indexOf(prid)==0)
+ map.getTo().addDBRef(
+ new DBRefEntry(ref.getSource(), ref.getVersion(), ref
+ .getAccessionId())); // don't copy map over.
+ if (map.getTo().getName().indexOf(prid) == 0)
{
- map.getTo().setName(jalview.datamodel.DBRefSource.UNIPROT+"|"+ref.getAccessionId());
+ map.getTo().setName(
+ jalview.datamodel.DBRefSource.UNIPROT + "|"
+ + ref.getAccessionId());
}
}
}
if (product != null)
{
DBRefEntry pref = new DBRefEntry(ref.getSource(), ref
- .getVersion(), ref.getAccessionId());
+ .getVersion(), ref.getAccessionId());
pref.setMap(null); // reference is direct
product.addDBRef(pref);
// Add converse mapping reference
pref = new DBRefEntry(sourceDb, getVersion(), this
.getAccession());
pref.setMap(pmap);
- if (map.getTo()!=null)
+ if (map.getTo() != null)
{
map.getTo().addDBRef(pref);
}