Skip to content

Commit

Permalink
exclude genes with 3 or less uniquely aligned sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed May 7, 2024
1 parent 581f881 commit 16a45c1
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/tree/TreeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -538,20 +538,28 @@ void alignGenes(int nThreads) {

void removeGaps() {
Prompt.print("Removing gappy columns with threshold of gap percentage " + filtering + "%...");

List<String> fileList = new ArrayList<>();

List<String> excludeList = new ArrayList<>();
for (String gene : usedGenes) {
fileList.add(alignedFinalGeneFastaFile(gene));
}

for (String fileName : fileList) {
String fileName = alignedFinalGeneFastaFile(gene);
FastaSeqList fsl = new FastaSeqList();
fsl.importFile(fileName);

String fasta = fsl.getString();
Prompt.talk("Removing gaps of sequences from " + fileName + "...");
if(filtering < 100) fasta = removeGapColumns(fasta);

fsl = new FastaSeqList();
fsl.importString(fasta);
HashSet<String> seqSet = new HashSet<>();
for(FastaSeq fs : fsl.list) {
seqSet.add(fs.sequence);
}
if(seqSet.size() < 4) {
Prompt.warn("Gene " + gene + " has less than 4 unique sequences. This gene will be excluded.");
excludeList.add(gene);
continue;
}

Prompt.talk("Writing result to " + fileName + "...");
try {
Expand All @@ -562,6 +570,9 @@ void removeGaps() {
ExceptionHandler.handle(e);
}
}
for (String gene : excludeList) {
usedGenes.remove(gene);
}
}

void concatenateAlignedGenes() {
Expand Down Expand Up @@ -1708,7 +1719,7 @@ private void retrieveFastaNucProFiles(List<GeneSetByGenomeDomain> geneSetsDomain
if(this.module == MODULE_TREE) deficient = nuc < 4 && pro < 4;

if(deficient) {
Prompt.warn("Less than 4 species have '" + gene + "'. This gene will be excluded");
Prompt.warn("Less than 4 species have '" + gene + "'. This gene will be excluded.");
}

if (sbNuc.length() != 0 && (!deficient)) {
Expand Down

0 comments on commit 16a45c1

Please sign in to comment.