-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dominika.kresa
committed
Jan 6, 2025
1 parent
cafa572
commit 269583f
Showing
2 changed files
with
83 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import argparse | ||
from Bio import SeqIO | ||
|
||
def remove_outgroup_records(failed_file, outgroup_file, output_file): | ||
# Read outgroup sequences | ||
outgroup_records = set() | ||
if outgroup_file: | ||
with open(outgroup_file, "r") as outgroup: | ||
for record in SeqIO.parse(outgroup, "fasta"): | ||
outgroup_records.add(record.id) | ||
|
||
# Filter failed file records | ||
with open(failed_file, "r") as failed, open(output_file, "w") as output: | ||
for record in SeqIO.parse(failed, "fasta"): | ||
if record.id not in outgroup_records: | ||
SeqIO.write(record, output, "fasta") | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Process failed file by removing outgroup records.") | ||
parser.add_argument("--failed", required=True, help="Path to the failed file (FASTA format).") | ||
parser.add_argument("--outgroup", required=False, help="Path to the outgroup file (FASTA format).") | ||
parser.add_argument("--output", required=True, help="Path to the output file (FASTA format).") | ||
args = parser.parse_args() | ||
|
||
remove_outgroup_records(args.failed, args.outgroup, args.output) |