Skip to content
Snippets Groups Projects
Commit 5c395693 authored by tjc's avatar tjc
Browse files

utility for writing out database sequences in EMBL format

git-svn-id: svn+ssh://svn.internal.sanger.ac.uk/repos/svn/pathsoft/artemis/trunk@9170 ee4ac58c-ac51-4696-9907-e4b3aa274f04
parent 769bc544
No related branches found
No related tags found
No related merge requests found
...@@ -43,7 +43,9 @@ public class ReadAndWriteEntry ...@@ -43,7 +43,9 @@ public class ReadAndWriteEntry
private static org.apache.log4j.Logger logger4j = private static org.apache.log4j.Logger logger4j =
org.apache.log4j.Logger.getLogger(ReadAndWriteEntry.class); org.apache.log4j.Logger.getLogger(ReadAndWriteEntry.class);
private static DatabaseEntrySource ENTRY_SOURCE;
/** /**
* Read from the database, given a srcFeature uniquename * Read from the database, given a srcFeature uniquename
* @param uniqueName * @param uniqueName
...@@ -52,16 +54,21 @@ public class ReadAndWriteEntry ...@@ -52,16 +54,21 @@ public class ReadAndWriteEntry
* @throws NoSequenceException * @throws NoSequenceException
* @throws IOException * @throws IOException
*/ */
public static Entry readEntryFromDatabase(final String uniqueName) public static Entry readEntryFromDatabase(final String uniqueName,
DatabaseEntrySource entry_source)
throws OutOfRangeException, NoSequenceException, IOException throws OutOfRangeException, NoSequenceException, IOException
{ {
final DatabaseEntrySource entry_source = new DatabaseEntrySource(); if(entry_source == null)
boolean promptUser = true; {
if(System.getProperty("read_only") != null) ReadAndWriteEntry.ENTRY_SOURCE = new DatabaseEntrySource();
promptUser = false; entry_source = ENTRY_SOURCE;
boolean promptUser = true;
if(System.getProperty("read_only") != null)
promptUser = false;
if(!entry_source.setLocation(promptUser)) if(!entry_source.setLocation(promptUser))
return null; return null;
}
String url = (String)entry_source.getLocation(); String url = (String)entry_source.getLocation();
int index = url.indexOf("?"); int index = url.indexOf("?");
...@@ -90,6 +97,20 @@ public class ReadAndWriteEntry ...@@ -90,6 +97,20 @@ public class ReadAndWriteEntry
stream_progress_listener); stream_progress_listener);
} }
/**
* Read from the database, given a srcFeature uniquename
* @param uniqueName
* @return
* @throws OutOfRangeException
* @throws NoSequenceException
* @throws IOException
*/
public static Entry readEntryFromDatabase(final String uniqueName)
throws OutOfRangeException, NoSequenceException, IOException
{
return readEntryFromDatabase(uniqueName, null);
}
/** /**
* Write entry to a file * Write entry to a file
* @param entry * @param entry
...@@ -200,47 +221,70 @@ public class ReadAndWriteEntry ...@@ -200,47 +221,70 @@ public class ReadAndWriteEntry
{ {
try try
{ {
/*Entry entry = ReadAndWriteEntry.readEntryFromDatabase("Pf3D7_03"); String names[];
ReadAndWriteEntry.writeDatabaseEntryToFile( boolean flatten = true;
entry, new File("Pf3D7_03.flatten"), true, true, false, boolean ignoreObsolete = true;
DocumentEntryFactory.EMBL_FORMAT, null);
ReadAndWriteEntry.writeDatabaseEntryToFile( if(args != null && args.length == 1 && args[0].startsWith("-h"))
entry, new File("Pf3D7_03.not-flatten"), false, true, false, {
DocumentEntryFactory.EMBL_FORMAT, null);*/ System.out.println("-h\tshow help");
System.out.println("-f\t[y|n] flatten the gene model, default is y");
// System.out.println("-i\t[y|n] ignore obsolete features, default is y");
// System.out.println("-s\tspace separated list of sequences to read and write out");
System.exit(0);
final String names[]; }
if(args == null || args.length < 1) if(args == null || args.length < 1)
names = new String[]{ names = new String[]{
"bin.fas", "bin.fas",
"chab01.fas", "chab01.fas",
"chab02.fas", "chab02.fas",
"chab03.fas",
"chab04.fas",
"chab05.fas",
"chab06.fas",
"chab07.fas",
"chab08.fas",
"chab09.fas",
"chab10.fas",
"chab11.fas",
"chab12.fas",
"chab13.fas",
"chab14.fas",
"chab99.fas" }; "chab99.fas" };
else else
{
names = args; names = args;
for(int i=0; i<args.length; i++)
if(args[i].toLowerCase().equals("-f"))
{
if(i+1<args.length && args[i+1].toLowerCase().equals("n"))
flatten = false;
}
for(int i=0; i<args.length; i++)
if(args[i].toLowerCase().equals("-i"))
{
if(i+1<args.length && args[i+1].toLowerCase().equals("n"))
ignoreObsolete = false;
}
java.util.Vector files = null;
for(int i=0; i<args.length; i++)
{
if(args[i].toLowerCase().equals("-s"))
{
files = new java.util.Vector();
for(int j=i+1; j<args.length; j++)
{
if(args[j].startsWith("-"))
break;
files.add(args[j]);
}
}
}
if(files != null && files.size() > 0)
{
names = new String[files.size()];
files.toArray(names);
}
}
for(int i=0;i < names.length; i++) for(int i=0;i < names.length; i++)
{ {
System.out.println(i+" "+names[i]); System.out.println(i+" read and write :: "+names[i]);
Entry entry = ReadAndWriteEntry.readEntryFromDatabase(names[i]); Entry entry = ReadAndWriteEntry.readEntryFromDatabase(names[i], ENTRY_SOURCE);
ReadAndWriteEntry.writeDatabaseEntryToFile( ReadAndWriteEntry.writeDatabaseEntryToFile(
entry, new File(names[i]+".embl"), true, true, false, entry, new File(names[i]+".embl"), flatten, ignoreObsolete, false,
DocumentEntryFactory.EMBL_FORMAT, null); DocumentEntryFactory.EMBL_FORMAT, null);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment