Skip to content
Snippets Groups Projects
Commit 7d37107b authored by gv1's avatar gv1
Browse files

added translation for polypeptide features (with Tim's help!)

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@11533 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 9f5b8e28
Branches
Tags
No related merge requests found
......@@ -20,15 +20,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFStreamFeature.java,v 1.68 2009-07-21 17:25:42 gv1 Exp $
* $Header: //tmp/pathsoft/artemis/uk/ac/sanger/artemis/io/GFFStreamFeature.java,v 1.69 2009-08-13 14:24:12 gv1 Exp $
*/
package uk.ac.sanger.artemis.io;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
import java.io.IOException;
......@@ -38,6 +42,7 @@ import java.text.SimpleDateFormat;
import uk.ac.sanger.artemis.Options;
import uk.ac.sanger.artemis.chado.ClusterLazyQualifierValue;
import uk.ac.sanger.artemis.components.genebuilder.GeneUtils;
import uk.ac.sanger.artemis.components.genebuilder.ProteinMapPanel;
import uk.ac.sanger.artemis.components.genebuilder.ortholog.MatchPanel;
import uk.ac.sanger.artemis.util.LinePushBackReader;
......@@ -50,7 +55,7 @@ import uk.ac.sanger.artemis.util.StringVector;
* A StreamFeature that thinks it is a GFF feature.
*
* @author Kim Rutherford
* @version $Id: GFFStreamFeature.java,v 1.68 2009-07-21 17:25:42 gv1 Exp $
* @version $Id: GFFStreamFeature.java,v 1.69 2009-08-13 14:24:12 gv1 Exp $
**/
public class GFFStreamFeature extends SimpleDocumentFeature
......@@ -94,6 +99,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
private boolean readOnlyFeature = false;
private static String MAP_DECODE[][] = {
{ " ", "%20" }, // white space
{ ",", "%2C" }, // comma
......@@ -188,6 +194,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
public GFFStreamFeature(final Feature feature)
{
this(feature, false);
}
/**
......@@ -200,6 +207,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature
{
this(feature.getKey(), feature.getLocation(), feature.getQualifiers());
if(feature instanceof GFFStreamFeature)
{
if(((GFFStreamFeature)feature).id_range_store != null)
......@@ -280,6 +289,9 @@ public class GFFStreamFeature extends SimpleDocumentFeature
}
catch(ReadOnlyException e){}
catch(EntryInformationException e){}
} else
{
chadoGene = ((GFFStreamFeature)feature).chadoGene;
}
}
}
......@@ -727,6 +739,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature
}
protected static Hashtable contig_ranges;
private Range this_range;
private String frame;
/**
* Write this Feature to the given stream.
......@@ -744,7 +758,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
for(int i = 0; i < ranges_size; ++i)
{
Range this_range = (Range)ranges.elementAt(i);
this_range = (Range)ranges.elementAt(i);
String seqname = getGffSeqName();
String source = getGffSource();
......@@ -790,7 +804,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
group = gene;
}
String frame = ".";
frame = ".";
final Qualifier codon_start = getQualifierByName("codon_start");
......@@ -876,6 +890,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature
"Derives_from",
"Target", "Gap", "Note",
"Dbxref", "Ontology_term" };
int count = 0;
Qualifier this_qualifier;
final int names_length = names.length;
......@@ -894,9 +910,16 @@ public class GFFStreamFeature extends SimpleDocumentFeature
if(this_qualifier == null)
continue;
if(this_qualifier.getValues().toString().length() <= 2)
continue;
// GSV :: see new getQualifierString signature
// this qualifier is one of the reserved qualifiers
final String this_qualifier_str = getQualifierString(this_qualifier, true);
if (this_qualifier_str.length() == 0)
continue;
if(this_qualifier_str == null)
continue;
......@@ -906,6 +929,8 @@ public class GFFStreamFeature extends SimpleDocumentFeature
count++;
}
addTranslation();
boolean lname;
final int qualifiers_size = qualifiers.size();
for(int i = 0; i < qualifiers_size; i++)
......@@ -935,6 +960,55 @@ public class GFFStreamFeature extends SimpleDocumentFeature
return buffer.toString();
}
/*
*
* Adds translations to polypeptide features.
*/
private void addTranslation()
{
if (! getKey().getKeyString().equals("polypeptide"))
return;
ChadoCanonicalGene ccg = this.chadoGene;
String id = this.getQualifierByName("ID").getValues().toString() ;
if (ccg != null)
{
@SuppressWarnings("unused")
uk.ac.sanger.artemis.Feature f = new uk.ac.sanger.artemis.Feature(this);
// the above line constructs the appropriate userData within this current GFFStreamFeature object,
// which is required by the following GeneUtils.deriveResidues()
String residues = GeneUtils.deriveResidues(this);
if (residues != null)
{
Qualifier translation = new Qualifier("translation");
translation.addValue(residues);
try {
setQualifier(translation);
} catch (Exception e) {
UI.warn(e.getMessage(), e.getClass().toString());
}
} else
{
UI.warn(id + " has no translatable residues, is pseudogene? " + ccg.getGene().getKey().getKeyString(), "empty residues");
}
} else
{
UI.warn(id + " has no ChadoCanonicalGene ", "no canonical gene");
Qualifier comment = new Qualifier("autogenerated_comment");
comment.addValue( "this polypeptide has no parent gene associated, probably unknown transcript" );
try {
setQualifier(comment);
} catch (Exception e) {
UI.warn(e.getMessage(), e.getClass().toString());
}
}
}
/**
* Used to write out the GFF attributes.
* @param q the qualifier to represent as a <code>String</code>
......@@ -970,7 +1044,7 @@ public class GFFStreamFeature extends SimpleDocumentFeature
*/
String nameToBuffer = encode(name);
if (! reserved)
nameToBuffer = Character.toLowerCase(nameToBuffer.charAt(0)) + nameToBuffer.substring(1);
nameToBuffer = nameToBuffer.toLowerCase(); //Character.toLowerCase(nameToBuffer.charAt(0)) + nameToBuffer.substring(1);
buffer.append(nameToBuffer);
if(values != null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment