Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fasta_compute_length: Add required file for Pulsar deployments and bump python to 3.12 #628

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/fasta_compute_length/.shed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ long_description: |
name: fasta_compute_length
owner: devteam
remote_repository_url: https://github.com/galaxyproject/tools-devteam/tree/master/tools/fasta_compute_length
homepage_url: https://github.com/galaxyproject/tools-devteam/tree/master/tools/fasta_compute_length
type: unrestricted
43 changes: 40 additions & 3 deletions tools/fasta_compute_length/fasta_compute_length.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,47 @@
#!/usr/bin/env python
"""
Uses fasta_to_len converter code.
Input: fasta, int
Output: tabular
Return titles with lengths of corresponding seq
"""

import sys
from utils.fasta_to_len import compute_fasta_length


compute_fasta_length(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] == 'id_only')
def compute_fasta_length(fasta_file, out_file, keep_first_char, keep_first_word=False):
keep_first_char = int(keep_first_char)
fasta_title = ''
seq_len = 0

# number of char to keep in the title
if keep_first_char == 0:
keep_first_char = None
else:
keep_first_char += 1

first_entry = True
with open(fasta_file) as in_fh, open(out_file, 'w') as out_fh:
for line in in_fh:
line = line.strip()
if not line or line.startswith('#'):
continue
if line[0] == '>':
if first_entry is False:
if keep_first_word:
fasta_title = fasta_title.split()[0]
out_fh.write("%s\t%d\n" % (fasta_title[1:keep_first_char], seq_len))
else:
first_entry = False
fasta_title = line
seq_len = 0
else:
seq_len += len(line)

# last fasta-entry
if keep_first_word:
fasta_title = fasta_title.split()[0]
out_fh.write("%s\t%d\n" % (fasta_title[1:keep_first_char], seq_len))


if __name__ == "__main__":
compute_fasta_length(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4] == 'id_only')
7 changes: 5 additions & 2 deletions tools/fasta_compute_length/fasta_compute_length.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<tool id="fasta_compute_length" name="Compute sequence length" version="1.0.3" profile="16.04">
<tool id="fasta_compute_length" name="Compute sequence length" version="1.0.4" profile="22.04">
<description></description>
<requirements>
<requirement type="package" version="3.7">python</requirement>
<requirement type="package" version="3.12">python</requirement>
</requirements>
<required_files>
<include path="fasta_compute_length.py"/>
nsoranzo marked this conversation as resolved.
Show resolved Hide resolved
</required_files>
<command>
#if $ref.ref_source == 'dbkey':
cp '${ref.index.fields.len_path}' '$output'
Expand Down
Empty file.
47 changes: 0 additions & 47 deletions tools/fasta_compute_length/utils/fasta_to_len.py

This file was deleted.