Skip to content

Commit

Permalink
Add extra fasta path checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Avtonomov authored and fcyu committed Dec 8, 2022
1 parent a2a351f commit 019ccd4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MSFragger-GUI/src/com/dmtavt/fragpipe/tabs/TabDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
Expand Down Expand Up @@ -234,12 +236,19 @@ public String getFastaPath() {

private void validateFasta(String path) {
try {
if (path != null && !Files.exists(Paths.get(path))) {
log.debug("Got bad FASTA path: {}", path);
Bus.postSticky(new NoteConfigDatabase());
return;
}
Path p = PathUtils.existing(path, true);
FastaContent fasta = FastaUtils.readFasta(p);
final String tag = getDecoyTag();
int decoysCnt = (int)FastaUtils.getDecoysCnt(fasta.ordered.get(0), tag);
int protsTotal = FastaUtils.getProtsTotal(fasta.ordered.get(0));
Bus.postSticky(new NoteConfigDatabase(Paths.get(path), protsTotal, decoysCnt, true));
} catch (AccessDeniedException e) {
log.warn("No access to FASTA file path: {}", path);
} catch (Exception e) {
log.debug("Got bad FASTA path: {}", path);
Bus.postSticky(new NoteConfigDatabase());
Expand Down

0 comments on commit 019ccd4

Please sign in to comment.