Permalink
Browse files

AP11-102: Create Runner for Reverse protein

Create a new runner for the reverse protein tool.
  • Loading branch information...
1 parent 2bce7e0 commit 0306c11ddc09e37a03614b8a538c7959c6d792f0 @diego-intersect diego-intersect committed Oct 28, 2012
View
1 .gitignore
@@ -10,3 +10,4 @@
build/
dist/
+out/
View
51 src/au/org/intersect/samifier/ReverseProtein.java
@@ -0,0 +1,51 @@
+package au.org.intersect.samifier;
+
+import au.org.intersect.samifier.runner.ReverseProteinRunner;
+import org.apache.commons.cli.*;
+
+import java.io.File;
+
+public class ReverseProtein
+{
+ public static void main(String[] args)
+ {
+ Option resultsFile = OptionBuilder.withArgName("searchResultsFile")
+ .hasArgs()
+ .withDescription("Mascot search results file in txt format")
+ .isRequired()
+ .create("r");
+
+ Option mappingFile = OptionBuilder.withArgName("mappingFile")
+ .hasArg()
+ .withDescription("File mapping protein identifier to ordered locus name")
+ .isRequired()
+ .create("m");
+
+ Options options = new Options();
+ options.addOption(resultsFile);
+ options.addOption(mappingFile);
+
+ CommandLineParser parser = new GnuParser();
+ try
+ {
+ CommandLine line = parser.parse( options, args );
+ String[] searchResultsPaths = line.getOptionValues("r");
+ File mapFile = new File(line.getOptionValue("m"));
+
+ ReverseProteinRunner reverseProteinRunner = new ReverseProteinRunner(searchResultsPaths, mapFile);
+ reverseProteinRunner.run();
+ }
+ catch (ParseException pe)
+ {
+ HelpFormatter formatter = new HelpFormatter();
+ formatter.printHelp("reverse_protein", options, true);
+ System.exit(1);
+ }
+ catch (Exception e)
+ {
+ System.err.println(e);
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+}
View
3 src/au/org/intersect/samifier/parser/PeptideSearchResultsParser.java
@@ -8,4 +8,7 @@
public interface PeptideSearchResultsParser
{
List<PeptideSearchResult> parseResults(File searchResultFile) throws MascotParsingException;
+
+ List<PeptideSearchResult> parseResults(String[] searchResultFiles) throws MascotParsingException;
+
}
View
25 src/au/org/intersect/samifier/parser/PeptideSearchResultsParserImpl.java
@@ -37,6 +37,31 @@ public PeptideSearchResultsParserImpl(Map<String,String> proteinToOLNMapping)
}
@Override
+ public List<PeptideSearchResult> parseResults(String[] searchResultsPaths) throws MascotParsingException
+ {
+ List<PeptideSearchResult> peptideSearchResults = new ArrayList<PeptideSearchResult>();
+ List<File> searchResultFiles = new ArrayList<File>();
+ for (String searchResultsPath : searchResultsPaths)
+ {
+ File searchResultFile = new File(searchResultsPath);
+ if (!searchResultFile.exists())
+ {
+ System.err.println(searchResultFile + " does not exist");
+ System.exit(1);
+ }
+ searchResultFiles.add(searchResultFile);
+ }
+
+ for (File searchResultFile : searchResultFiles)
+ {
+ LOG.debug("Processing: " + searchResultFile.getAbsolutePath());
+ peptideSearchResults.addAll(parseResults(searchResultFile));
+ }
+ return peptideSearchResults;
+ }
+
+
+ @Override
public List<PeptideSearchResult> parseResults(File searchResultFile) throws MascotParsingException
{
try
View
34 src/au/org/intersect/samifier/runner/ReverseProteinRunner.java
@@ -0,0 +1,34 @@
+package au.org.intersect.samifier.runner;
+
+import au.org.intersect.samifier.domain.PeptideSearchResult;
+import au.org.intersect.samifier.parser.PeptideSearchResultsParser;
+import au.org.intersect.samifier.parser.PeptideSearchResultsParserImpl;
+import au.org.intersect.samifier.parser.ProteinToOLNParser;
+import au.org.intersect.samifier.parser.ProteinToOLNParserImpl;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+public class ReverseProteinRunner
+{
+ private String[] searchResultsPaths;
+ private Map<String,String> proteinToOLNMap;
+ private File mapFile;
+
+ public ReverseProteinRunner(String[] searchResultsPaths, File mapFile)
+ {
+ this.searchResultsPaths = searchResultsPaths;
+ this.mapFile = mapFile;
+ }
+
+ public void run() throws Exception
+ {
+ ProteinToOLNParser proteinToOLNParser = new ProteinToOLNParserImpl();
+ proteinToOLNMap = proteinToOLNParser.parseMappingFile(mapFile);
+
+ PeptideSearchResultsParser peptideSearchResultsParser = new PeptideSearchResultsParserImpl(proteinToOLNMap);
+ List<PeptideSearchResult> peptideSearchResults = peptideSearchResultsParser.parseResults(searchResultsPaths);
+
+ }
+}
View
20 src/au/org/intersect/samifier/runner/SamifierRunner.java
@@ -53,25 +53,7 @@ public void run() throws Exception
proteinToOLNMap = proteinToOLNParser.parseMappingFile(mapFile);
PeptideSearchResultsParser peptideSearchResultsParser = new PeptideSearchResultsParserImpl(proteinToOLNMap);
-
- List<PeptideSearchResult> peptideSearchResults = new ArrayList<PeptideSearchResult>();
- List<File> searchResultFiles = new ArrayList<File>();
- for (String searchResultsPath : searchResultsPaths)
- {
- File searchResultFile = new File(searchResultsPath);
- if (!searchResultFile.exists())
- {
- System.err.println(searchResultFile + " does not exist");
- System.exit(1);
- }
- searchResultFiles.add(searchResultFile);
- }
-
- for (File searchResultFile : searchResultFiles)
- {
- LOG.debug("Processing: " + searchResultFile.getAbsolutePath());
- peptideSearchResults.addAll(peptideSearchResultsParser.parseResults(searchResultFile));
- }
+ List<PeptideSearchResult> peptideSearchResults = peptideSearchResultsParser.parseResults(searchResultsPaths);
FileWriter bedWriter = null;
if (bedfilePath != null)

0 comments on commit 0306c11

Please sign in to comment.