Skip to content
Snippets Groups Projects
Commit 38ce6003 authored by tcarver's avatar tcarver
Browse files

optionally remove product qualifier from CDS marked as a pseudogene

parent f3c18d0c
No related branches found
No related tags found
No related merge requests found
......@@ -366,17 +366,21 @@ public class EntryFileDialog extends StickyFileChooser
Box yBox = Box.createVerticalBox();
boolean useAccessory = false;
JCheckBox emblHeader = new JCheckBox("Add EMBL Header",
false);
JCheckBox emblHeader = new JCheckBox("Add EMBL Header", false);
JCheckBox removeProductForPseudo = new JCheckBox(
"Remove products from pseudogenes", false);
setDialogTitle("Save to ...");
setDialogType(JFileChooser.SAVE_DIALOG);
if( destination_type == DocumentEntryFactory.EMBL_FORMAT &&
(entry.getHeaderText() == null ||
!isHeaderEMBL(entry.getHeaderText())) )
if( destination_type == DocumentEntryFactory.EMBL_FORMAT )
{
yBox.add(emblHeader);
if((entry.getHeaderText() == null || !isHeaderEMBL(entry.getHeaderText())))
yBox.add(emblHeader);
if(!include_diana_extensions)
yBox.add(removeProductForPseudo);
useAccessory = true;
}
......@@ -466,12 +470,13 @@ public class EntryFileDialog extends StickyFileChooser
false);
try
{
DocumentEntryFactory.REMOVE_PRODUCT_FROM_PSEUDOGENE = removeProductForPseudo.isSelected();
if(entry.getEMBLEntry() instanceof DatabaseDocumentEntry ||
entry.getEMBLEntry() instanceof GFFDocumentEntry)
ReadAndWriteEntry.writeDatabaseEntryToFile(entry, file,
flattenGeneModel.isSelected(),
ignoreObsoleteFeatures.isSelected(), false,
include_diana_extensions, false, destination_type, owner);
include_diana_extensions, destination_type, owner);
else if(include_diana_extensions)
entry.save(file, destination_type, false);
else
......@@ -491,7 +496,7 @@ public class EntryFileDialog extends StickyFileChooser
ReadAndWriteEntry.writeDatabaseEntryToFile(entry, file,
flattenGeneModel.isSelected(),
ignoreObsoleteFeatures.isSelected(), true,
include_diana_extensions, false, destination_type, null);
include_diana_extensions, destination_type, null);
else if(include_diana_extensions)
entry.save(file, destination_type, true);
else
......@@ -507,6 +512,7 @@ public class EntryFileDialog extends StickyFileChooser
}
finally
{
DocumentEntryFactory.REMOVE_PRODUCT_FROM_PSEUDOGENE = false;
if(message != null)
message.dispose();
}
......
......@@ -48,47 +48,18 @@ abstract public class DocumentEntryFactory
/** use if format of the entry is not important */
final public static int ANY_FORMAT = UNKNOWN_FORMAT;
/** use for an entry that is in EMBL format */
final public static int EMBL_FORMAT = 1;
/** use for an entry that is in GENBANK format */
final public static int GENBANK_FORMAT = 2;
/** use for an entry that is in GFF format */
final public static int GFF_FORMAT = 3;
/** use for an entry that is in BSML format */
final public static int BSML_FORMAT = 4;
/** use for an entry that is in GAME format */
final public static int GAME_FORMAT = 5;
/** use for an entry that is in AVAGE format */
final public static int AVAGE_FORMAT = 5;
/**
* Read a DocumentEntry object from the given Document with no restrictions
* on the possible keys and qualifiers.
* @param listener The object that will listen for ReadEvents.
**/
/* private static DocumentEntry makeDocumentEntry (final Document document,
final ReadListener listener)
throws IOException
{
try
{
final EntryInformation entry_information =
SimpleEntryInformation.getDefaultEntryInformation ();
public static boolean REMOVE_PRODUCT_FROM_PSEUDOGENE = false;
return makeDocumentEntry (entry_information, document, listener);
}
catch (EntryInformationException e)
{
throw new Error ("internal error - unexpected exception: " + e);
}
}*/
/**
* Read a DocumentEntry object from the given Document.
......@@ -161,27 +132,6 @@ abstract public class DocumentEntryFactory
}
}
/**
* Make a new (nameless) DocumentEntry from the given Entry. The new Entry
* will have a copy of the EntryInformation object of the argument Entry.
* @param destination_type This parameter control the type of DocumentEntry
* that is created. It should be a DocumentEntry type that can be
* constructed from any Entry eg. one of EMBL_FORMAT, GENBANK_FORMAT.
* @exception EntryInformationException Thrown if the destination Entry
* cannot contain the Key, Qualifier or Key/Qualifier combination of one
* of the features in the source Entry.
**/
/* public static DocumentEntry makeDocumentEntry (final Entry entry,
final int destination_type)
throws EntryInformationException
{
final EntryInformation entry_information =
new SimpleEntryInformation (entry.getEntryInformation ());
return makeDocumentEntry (entry_information, entry, destination_type,
false);
}*/
/**
* Make a new (nameless) DocumentEntry from the given Entry.
* @param entry_information The EntryInformation to use for the new object.
......@@ -229,7 +179,12 @@ abstract public class DocumentEntryFactory
switch (destination_type) {
case EMBL_FORMAT:
return new EmblDocumentEntry (entry_information, entry, force);
{
EmblDocumentEntry ee = new EmblDocumentEntry (entry_information, entry, force);
if(force)
removeProductFromPseudogene(ee, destination_type);
return ee;
}
case GENBANK_FORMAT:
return new GenbankDocumentEntry (entry_information, entry, force);
case GFF_FORMAT:
......@@ -242,4 +197,31 @@ abstract public class DocumentEntryFactory
throw new Error ("internal error - unknown DocumentEntry type");
}
}
/**
* Remove product qualifier from CDS features with pseudogene qualifier
* @param document_entry
* @param destination_type
* @throws EntryInformationException
*/
private static void removeProductFromPseudogene(final DocumentEntry entry,
final int destination_type)
throws EntryInformationException
{
if( !REMOVE_PRODUCT_FROM_PSEUDOGENE )
return;
final FeatureVector features = entry.getAllFeatures();
for(Feature f: features)
{
if(f.getKey().equals("CDS"))
{
Qualifier q = f.getQualifierByName("product");
if( q != null &&
(f.getQualifierByName("pseudogene") != null ||
f.getQualifierByName("pseudo") != null))
f.getQualifiers().remove(q);
}
}
}
}
......@@ -136,7 +136,6 @@ public class ReadAndWriteEntry
final boolean ignoreObsolete,
final boolean force,
final boolean include_diana_extensions,
final boolean removeProductForPseudo,
final int destination_type,
final JFrame parent)
throws IOException, EntryInformationException
......@@ -184,27 +183,7 @@ public class ReadAndWriteEntry
if(include_diana_extensions)
entry.save(file, destination_type, force, artemis_entry_information);
else
{
if(removeProductForPseudo)
{
uk.ac.sanger.artemis.io.FeatureVector features = entry.getEMBLEntry().getAllFeatures();
for(Feature f: features)
{
if(f.getKey().equals("polypeptide"))
{
Qualifier q = f.getQualifierByName("product");
if(q != null)
{
Feature gene = ((GFFStreamFeature) f).getChadoGene().getGene();
if(gene.getKey().equals("pseudogene"))
f.getQualifiers().remove(q);
}
}
}
}
entry.saveStandardOnly(file, destination_type, force);
}
}
......@@ -325,7 +304,7 @@ public class ReadAndWriteEntry
System.out.println("-z\t[y|n] gzip output, default is y");
System.out.println("-a\t[y|n] for EMBL submission format change to n, default is y");
System.out.println("-pp\t[y|n] read polypeptide domain features, default is n");
System.out.println("-r\t[y|n] remove product qualifiers from pseudogene, default is n");
System.out.println("-r\t[y|n] remove product qualifiers from pseudogene (only for EMBL submission format), default is n");
System.out.println("-c\tthe URL for your Chado database e.g. db.genedb.org:5432/snapshot?genedb_ro (if not using default)");
System.out.println("-u\t[swing|console|script] the UI mode : run in swing (with popup dialog boxes) mode, run in console mode (choices entered in the console window), or in script mode (all choices default to continue, all parameters passed on command line) ");
System.out.println("-p\tthe password for connecting to the Chado database");
......@@ -466,13 +445,12 @@ public class ReadAndWriteEntry
logger4j.info("read :: "+names[i]+" write :: "+names[i]+suffix);
Entry entry = ReadAndWriteEntry.readEntryFromDatabase(names[i], ENTRY_SOURCE);
DocumentEntryFactory.REMOVE_PRODUCT_FROM_PSEUDOGENE = removeProductForPseudo;
try
{
ReadAndWriteEntry.writeDatabaseEntryToFile(
entry, new File(filePath + names[i]+suffix), flatten, ignoreObsolete,
false, include_diana_extensions, removeProductForPseudo,
format, null);
false, include_diana_extensions, format, null);
System.out.println("done");
logger4j.info("done");
}
......@@ -485,7 +463,7 @@ public class ReadAndWriteEntry
{
ReadAndWriteEntry.writeDatabaseEntryToFile(entry, new File(filePath + names[i] + suffix),
flatten, ignoreObsolete, true,
include_diana_extensions, removeProductForPseudo, format, null);
include_diana_extensions, format, null);
System.out.println("done");
logger4j.info("done");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment