Skip to content

Commit c968e2d

Browse files
committed
Fix some issues with protein prophet
1 parent 54fab72 commit c968e2d

File tree

10 files changed

+312
-118
lines changed

10 files changed

+312
-118
lines changed

build.gradle

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group = 'com.dmtavt'
12-
version = '1.0'
12+
version = '1.1'
1313

1414
description = """DeltaMass - detection and visualization of common mass shifts in proteomic searches."""
1515

@@ -29,7 +29,12 @@ jar {
2929

3030
shadowJar {
3131
classifier = null
32-
minimize()
32+
minimize {
33+
exclude(dependency('javax.xml.bind:jaxb-api:.*'))
34+
exclude(dependency('org.glassfish.jaxb:jaxb-runtime:.*'))
35+
exclude(dependency('javax.activation:javax.activation-api:.*'))
36+
exclude(dependency('com.sun.istack:istack-commons-runtime:.*'))
37+
}
3338
}
3439

3540
launch4j {
@@ -46,19 +51,19 @@ repositories {
4651
}
4752
dependencies {
4853
// our projects
49-
implementation("com.github.chhh:dmtavt-utils:0.4.4")
50-
implementation("com.github.chhh:msftbx:1.8.6")
51-
implementation("com.github.chhh:ptm-factory:1.0")
52-
implementation("edu.umich.andykong:mscalibrator:1.1")
54+
compile("com.github.chhh:dmtavt-utils:0.4.4")
55+
compile("com.github.chhh:msftbx:1.8.6")
56+
compile("com.github.chhh:ptm-factory:1.0")
57+
compile("edu.umich.andykong:mscalibrator:1.1")
5358

5459
// basic
55-
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
56-
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
57-
implementation group: 'com.beust', name: 'jcommander', version: '1.72'
60+
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
61+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
62+
compile group: 'com.beust', name: 'jcommander', version: '1.72'
5863

5964
// commons
60-
implementation group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
61-
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
65+
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
66+
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
6267
compile 'commons-io:commons-io:2.6'
6368

6469
// other
@@ -67,17 +72,22 @@ dependencies {
6772
compile 'com.miglayout:miglayout-swing:5.2'
6873
compile 'org.jfree:jfreechart:1.5.0'
6974

70-
implementation group: 'com.edwardraff', name: 'JSAT', version: '0.0.9'
71-
implementation(group: 'com.github.haifengl', name: 'smile-core', version: '1.5.2') {
75+
compile(group: 'com.edwardraff', name: 'JSAT', version: '0.0.9')
76+
compile(group: 'com.github.haifengl', name: 'smile-core', version: '1.5.2') {
7277
exclude(module: 'smile-data')
7378
exclude(module: 'smile-graph')
7479
}
7580

81+
// JAXB stuff for parsing mods from databases
82+
compile 'javax.xml.bind:jaxb-api:2.3.1'
83+
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
84+
compile 'javax.activation:javax.activation-api:1.2.0'
85+
7686
// downloaded / precompiled jars
7787
compile fileTree(dir: 'libs', include: '*.jar')
7888

7989
// test
80-
testImplementation(group: 'org.apache.maven', name: 'maven-model', version: '3.6.0')
81-
testImplementation group: 'junit', name: 'junit', version: '4.12'
90+
testCompile(group: 'org.apache.maven', name: 'maven-model', version: '3.6.0')
91+
testCompile group: 'junit', name: 'junit', version: '4.12'
8292
testCompile("org.assertj:assertj-core:3.11.1")
8393
}

build.xml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- You may freely edit this file. See commented blocks below for -->
3+
<!-- some examples of how to customize the build. -->
4+
<!-- (If you delete it and reopen the project it will be recreated.) -->
5+
<!-- By default, only the Clean and Build commands use this build script. -->
6+
<!-- Commands such as Run, Debug, and Test only use this build script if -->
7+
<!-- the Compile on Save feature is turned off for the project. -->
8+
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9+
<!-- in the project's Project Properties dialog box.-->
10+
<project basedir="." default="default" name="DeltaMass">
11+
<description>Builds, tests, and runs the project DeltaMass.</description>
12+
<import file="nbproject/build-impl.xml"/>
13+
<!--
14+
15+
There exist several targets which are by default empty and which can be
16+
used for execution of your tasks. These targets are usually executed
17+
before and after some main targets. They are:
18+
19+
-pre-init: called before initialization of project properties
20+
-post-init: called after initialization of project properties
21+
-pre-compile: called before javac compilation
22+
-post-compile: called after javac compilation
23+
-pre-compile-single: called before javac compilation of single file
24+
-post-compile-single: called after javac compilation of single file
25+
-pre-compile-test: called before javac compilation of JUnit tests
26+
-post-compile-test: called after javac compilation of JUnit tests
27+
-pre-compile-test-single: called before javac compilation of single JUnit test
28+
-post-compile-test-single: called after javac compilation of single JUunit test
29+
-pre-jar: called before JAR building
30+
-post-jar: called after JAR building
31+
-post-clean: called after cleaning build products
32+
33+
(Targets beginning with '-' are not intended to be called on their own.)
34+
35+
Example of inserting an obfuscator after compilation could look like this:
36+
37+
<target name="-post-compile">
38+
<obfuscate>
39+
<fileset dir="${build.classes.dir}"/>
40+
</obfuscate>
41+
</target>
42+
43+
For list of available properties check the imported
44+
nbproject/build-impl.xml file.
45+
46+
47+
Another way to customize the build is by overriding existing main targets.
48+
The targets of interest are:
49+
50+
-init-macrodef-javac: defines macro for javac compilation
51+
-init-macrodef-junit: defines macro for junit execution
52+
-init-macrodef-debug: defines macro for class debugging
53+
-init-macrodef-java: defines macro for class execution
54+
-do-jar: JAR building
55+
run: execution of project
56+
-javadoc-build: Javadoc generation
57+
test-report: JUnit report generation
58+
59+
An example of overriding the target for project execution could look like this:
60+
61+
<target name="run" depends="DeltaMass-impl.jar">
62+
<executorDefSize dir="bin" executable="launcher.exe">
63+
<arg file="${dist.jar}"/>
64+
</executorDefSize>
65+
</target>
66+
67+
Notice that the overridden target depends on the jar target and not only on
68+
the compile target as the regular run target does. Again, for a list of available
69+
properties which you can use, check the target you are overriding in the
70+
nbproject/build-impl.xml file.
71+
72+
-->
73+
74+
<target depends="jar" name="package-for-store">
75+
<property name="store.jar.name" value="DeltaMass"/>
76+
<property name="store.dir" value="dist"/>
77+
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
78+
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
79+
<delete dir="${store.dir}"/>
80+
<mkdir dir="${store.dir}"/>
81+
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
82+
<zipgroupfileset dir="dist" includes="*.jar"/>
83+
<zipgroupfileset dir="dist/lib" includes="*.jar"/>
84+
<manifest>
85+
<attribute name="Main-Class" value="${main.class}"/>
86+
</manifest>
87+
</jar>
88+
<zip destfile="${store.jar}">
89+
<zipfileset excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"
90+
src="${store.dir}/temp_final.jar"/>
91+
</zip>
92+
<delete file="${store.dir}/temp_final.jar"/>
93+
</target>
94+
95+
<!-- Creating manifest for NetBeans Ant builds -->
96+
<target name="-pre-init">
97+
<!-- Not needed, turns out you can just put stuff in manifest.mf file in
98+
the project root directory -->
99+
</target>
100+
101+
</project>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deltamass.version.current=0.1-SNAPSHOT
1+
deltamass.version.current=1.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deltamass.version.current=1.0
1+
deltamass.version.current=1.1

src/main/java/com/dmtavt/deltamass/DeltaMassInfo.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ public final class DeltaMassInfo {
2020
private static final EventBus bus = EventBus.getDefault();
2121

2222
public static final String Name = "DeltaMass";
23-
public static final String Ver = "1.0";
23+
public static final String Ver = "1.1";
2424

2525
private static final String PROP_VER = "deltamass.version.current";
2626
private static final String PROP_DOWNLOAD_URL = "deltamass.download.url";
2727
private static final String DEFAULT_DOWNLOAD_URL = "https://github.com/chhh/deltamass/releases";
28-
private static final String BUNDLE_PATH = "com/dmtavt/deltamass/Bundle";
28+
private static final String BUNDLE_PATH = "com/dmtavt/deltamass/Bundle.properties";
2929
private static final String BUNDLE_URL =
30-
"https://raw.githubusercontent.com/chhh/deltamass/master/src/main/java/" + BUNDLE_PATH
31-
+ ".properties";
30+
"https://raw.githubusercontent.com/chhh/deltamass/master/src/main/java/" + BUNDLE_PATH;
3231
private static final URI BUNDLE_URI = URI.create(BUNDLE_URL);
3332

3433
private DeltaMassInfo() {

src/main/java/com/dmtavt/deltamass/logic/LogicClean.java

Lines changed: 44 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,45 @@ public LogicClean(CommandClean cmd) {
2525

2626
public void run() {
2727
log.info("Running cleanup");
28-
if (cmd.dryRun) log.info("Dry-run, won't take any action.");
29-
int stepsPerformed = 0;
28+
final List<Path> scheduledForDeletion = getScheduledForDeletion();
3029

31-
if (!cmd.noPep) {
32-
stepsPerformed++;
33-
log.info("Cleaning up peptide identification files.");
34-
DeletionStats stats = deleteMatchingFilesInSubtrees(cmd.inputFiles,
35-
CacheLocator::isPepCacheFile, cmd.dryRun);
36-
log.info("Pep ID cleanup summary: scheduled: {}, deleted: {}, skipped: {}, error: {}",
37-
stats.scheduled, stats.deleted, stats.skipped.size(), stats.error.size());
38-
}
30+
final String list = scheduledForDeletion.stream().map(Path::toString)
31+
.collect(Collectors.joining("\n"));
32+
log.info("Files to delete:\n" + list);
3933

40-
if (!cmd.noLcms) {
41-
stepsPerformed++;
42-
log.info("Cleaning up LC-MS calibration files.");
43-
DeletionStats stats = deleteMatchingFilesInSubtrees(cmd.inputFiles,
44-
CacheLocator::isCalCacheFile, cmd.dryRun);
45-
log.info("Calibration cleanup summary: scheduled: {}, deleted: {}, skipped: {}, error: {}",
46-
stats.scheduled, stats.deleted, stats.skipped.size(), stats.error.size());
34+
if (cmd.dryRun) {
35+
log.info("Dry-run, won't take any action.");
36+
return;
4737
}
4838

49-
if (stepsPerformed == 0) log.info("You made it clear that nothing should be cleaned up. Doing nothing.");
39+
DeletionStats stats = delete(scheduledForDeletion);
40+
log.info("Cleanup: deleted {}/{}, errors: {}", stats.deleted.size(), stats.scheduled.size(), stats.error.size());
41+
}
42+
43+
private static List<Path> modifyInputPathsForCacheDeletion(List<Path> paths) {
44+
List<Path> possibleCachePaths = new ArrayList<>();
45+
for (Path inputFile : paths) {
46+
if (Files.isDirectory(inputFile)) {
47+
possibleCachePaths.add(inputFile);
48+
} else {
49+
Path parent = inputFile.getParent();
50+
Path fn = inputFile.getFileName();
51+
possibleCachePaths.add(parent.resolve(fn.toString() + CacheLocator.CACHE_EXT_PEP));
52+
possibleCachePaths.add(parent.resolve(fn.toString() + CacheLocator.CACHE_EXT_CAL));
53+
}
54+
}
55+
return possibleCachePaths;
5056
}
5157

5258
public List<Path> getScheduledForDeletion() {
5359
List<Path> delete = new ArrayList<>();
60+
final List<Path> putativeCachePaths = modifyInputPathsForCacheDeletion(cmd.inputFiles);
61+
5462
if (!cmd.noPep) {
55-
delete.addAll(getScheduledForDeletion(cmd.inputFiles, CacheLocator::isPepCacheFile));
63+
delete.addAll(getScheduledForDeletion(putativeCachePaths, CacheLocator::isPepCacheFile));
5664
}
5765
if (!cmd.noLcms) {
58-
delete.addAll(getScheduledForDeletion(cmd.inputFiles, CacheLocator::isCalCacheFile));
66+
delete.addAll(getScheduledForDeletion(putativeCachePaths, CacheLocator::isCalCacheFile));
5967
}
6068
return delete;
6169
}
@@ -89,73 +97,34 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
8997
log.warn("Error collecting files for deletion in subtree: {}" + path, e);
9098
}
9199
} else {
92-
if (condition.test(path)) {
100+
if (Files.exists(path) && condition.test(path)) {
93101
delete.add(path);
94102
}
95103
}
96104
}
97105
return new ArrayList<>(delete);
98106
}
99107

100-
private class DeletionStats {
101-
int scheduled = 0;
102-
int deleted = 0;
103-
ConcurrentLinkedQueue<Path> skipped = new ConcurrentLinkedQueue<>();
108+
private static class DeletionStats {
109+
ConcurrentLinkedQueue<Path> scheduled = new ConcurrentLinkedQueue<>();
110+
ConcurrentLinkedQueue<Path> deleted = new ConcurrentLinkedQueue<>();
104111
ConcurrentLinkedQueue<Path> error = new ConcurrentLinkedQueue<>();
105112
}
106113

107-
private DeletionStats deleteMatchingFilesInSubtrees(Iterable<? extends Path> paths, Predicate<? super Path> condition, boolean dryRun) {
108-
final ConcurrentLinkedQueue<Path> delete = new ConcurrentLinkedQueue<>();
109-
final DeletionStats stats = new DeletionStats();
110-
111-
for (Path path : paths) {
112-
if (Files.isDirectory(path)) {
113-
try {
114-
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
115-
@Override
116-
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
117-
if (!Files.isReadable(dir)) return FileVisitResult.SKIP_SUBTREE;
118-
return FileVisitResult.CONTINUE;
119-
}
120-
121-
@Override
122-
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
123-
if (!Files.isWritable(file)) {
124-
log.warn("File not writeable, skipping: {}", file);
125-
stats.skipped.add(file);
126-
return FileVisitResult.CONTINUE;
127-
}
128-
if (condition.test(file)) delete.add(file);
129-
return FileVisitResult.CONTINUE;
130-
}
131-
});
132-
} catch (IOException e) {
133-
log.error("Error collecting files for deletion in subtree: {}" + path, e);
134-
}
135-
} else {
136-
if (CacheLocator.isPepCacheFile(path))
137-
delete.add(path);
138-
}
139-
}
140-
141-
if (!delete.isEmpty()) {
142-
log.info("Files scheduled for deletion:\n {}",
143-
delete.stream().map(Path::toString).collect(Collectors.joining("\n ")));
144-
} else {
145-
log.info("Found no files to delete.");
146-
}
147-
stats.scheduled = delete.size();
148-
149-
if (!dryRun) delete.forEach(path -> {
114+
public static DeletionStats delete(List<Path> pathsToDelete) {
115+
DeletionStats ds = new DeletionStats();
116+
ds.scheduled.addAll(pathsToDelete);
117+
for (Path path : pathsToDelete) {
150118
try {
151-
Files.deleteIfExists(path);
152-
stats.deleted++;
119+
if (Files.deleteIfExists(path)) {
120+
ds.deleted.add(path);
121+
}
153122
} catch (IOException e) {
154-
log.error("Could not delete file: " + path, e);
155-
stats.error.add(path);
123+
log.error("Error deleting file: " + path.toString() + "\nDetails:\n" + e.getMessage());
124+
ds.error.add(path);
156125
}
157-
});
158-
159-
return stats;
126+
}
127+
return ds;
160128
}
129+
161130
}

src/main/java/com/dmtavt/deltamass/logic/LogicInputFiles.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ private List<Path> inputFiles(List<Path> inputPaths, final Pattern regex, boolea
259259
return matched;
260260
}
261261

262+
private boolean isPepFileSupported(Path pepFilePath) {
263+
IParserFactory<IPepidParser> parser = PepidParserRegistry.find(pepFilePath);
264+
return parser != null;
265+
}
266+
262267
private List<Path> collectSupportedFiles(Iterable<? extends Path> paths, boolean recursive) {
263268
final ConcurrentLinkedQueue<Path> supported = new ConcurrentLinkedQueue<>();
264269

@@ -280,8 +285,7 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
280285

281286
@Override
282287
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
283-
IParserFactory<IPepidParser> parser = PepidParserRegistry.find(file);
284-
if (parser != null) {
288+
if (isPepFileSupported(file)) {
285289
supported.add(file);
286290
}
287291
return FileVisitResult.CONTINUE;
@@ -292,8 +296,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
292296
log.warn("Error collecting files for deletion in subtree: {}" + path, e);
293297
}
294298
} else {
295-
if (CacheLocator.isPepCacheFile(path))
299+
// given a regular file, not a directory
300+
if (isPepFileSupported(path)) {
296301
supported.add(path);
302+
}
297303
}
298304
}
299305
return new ArrayList<>(supported);

0 commit comments

Comments
 (0)