Skip to content

Commit

Permalink
restoring functionality as a standalone script
Browse files Browse the repository at this point in the history
  • Loading branch information
Dfupa committed Dec 15, 2023
1 parent 043ef7d commit 84d45e1
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/fasta2homozygous.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,24 +334,30 @@ def main():

parser.add_argument('--version', action='version', version='1.01d')
parser.add_argument("-v", "--verbose", default=False, action="store_true", help="verbose")
parser.add_argument("-i", "-f", "--fasta", nargs="+", type=argparse.FileType('w'), help="FASTA file(s)")
parser.add_argument("-i", "-f", "--fasta", nargs="+", type=argparse.FileType('r+'), help="FASTA file(s)")
parser.add_argument("-t", "--threads", default=4, type=int, help="max threads to run [%(default)s]")
parser.add_argument("--identity", default=0.51, type=float, help="min. identity [%(default)s]")
parser.add_argument("--overlap", default=0.8, type=float, help="min. overlap [%(default)s]")
parser.add_argument("--minLength", default=200, type=int, help="min. contig length [%(default)s]")
parser.add_argument("--useminimap2", action='store_true', help="Use Minimap2 for aligning reads. Preset for ref vs ref: -PD -m200 -w 19")
parser.add_argument("--preset", default='asm10', help="Preset option for minimap2. Possible options: asm5 (5 percent sequence divergence), asm10 (10 percent sequence divergence) and asm20(20 percent sequence divergence). Default [%(default)s]")


#If executed as a single program:
src = ["bwa/", "snap/", "last/build/", "minimap2/misc/",
"last/bin/", "last/src/", "minimap2/", "miniasm/"]
paths = [os.path.join(root, p) for p in src]
os.environ["PATH"] = os.pathsep.join(paths + [os.environ["PATH"]])


o = parser.parse_args()
if o.verbose:
sys.stderr.write("Options: %s\n"%str(o))

#process fasta
sys.stderr.write("Homozygous assembly/ies will be written with input name + '.homozygous.fa.gz'\n")
sys.stderr.write("Homozygous assembly/ies will be written with input name + '.homozygous.fa'\n")
sys.stderr.write("#file name\tgenome size\tcontigs\theterozygous size\t[%]\theterozygous contigs\t[%]\tidentity [%]\tpossible joins\thomozygous size\t[%]\thomozygous contigs\t[%]\n")
for fasta in o.fasta:
out = gzip.open(fasta.name+".homozygous.fa.gz", "w")
out = open(fasta.name+".homozygous.fa", "w")
fasta2homozygous(out, fasta, o.identity, o.overlap, o.minLength, o.threads, o.verbose, o.useminimap2, o.preset)
out.close()

Expand Down

1 comment on commit 84d45e1

@Dfupa
Copy link
Contributor Author

@Dfupa Dfupa commented on 84d45e1 Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing issue #106

Please sign in to comment.