Skip to content
New issue

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

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

Already on GitHub? # to your account

PairwiseAlignment() function issues #2

Open
connerCpowell opened this issue Jun 26, 2018 · 1 comment
Open

PairwiseAlignment() function issues #2

connerCpowell opened this issue Jun 26, 2018 · 1 comment

Comments

@connerCpowell
Copy link

First, I would like to say thank you for the PyMS software! I think it is incredibly robust, efficient and user-friendly! I am enjoying using it very much.
Currently, I am struggling to get the PairwiseAlignment() function to work. I have attached the script I am developing to the end of this doc and below is the error I am receiving:

File "/home/cocopalacelove/easyGC/aligner.py", line 46, in align
    T1 = PairwiseAlignment(F1, Dw, Gw)
  File "/home/cocopalacelove/easyGC/pyms/Peak/List/DPA/Class.py", line 842, in __init__
    self.tree = self._guide_tree(self.dist_matrix)
  File "/home/cocopalacelove/easyGC/pyms/Peak/List/DPA/Class.py", line 918, in _guide_tree
    tree = Pycluster.treecluster(distancematrix=dist_matrix, method='a')
TypeError: treecluster() takes at least 1 argument (2 given)

A little about me, I am a researcher at the Carnegie Institute using GC-MS data to determine how secondary metabolites different across berry varieties. PyMS seems like the perfect tool to pre-process my data and it has been working great.

Any guidance on how to overcome this issue would be deeply appreciated!

Here is my script:

import fnmatch
import sys, os
from pyms.Experiment.IO import load_expr
from pyms.Peak.List.DPA.Class import PairwiseAlignment
from pyms.Peak.List.DPA.Function import align_with_tree, exprl2alignment

def glob(glob_pattern, directoryname):
    '''
    Walks through a directory and its subdirectories looking for files matching
    the glob_pattern and returns a list=[].

    :param directoryname: Any accessible folder name on the filesystem.
    :param glob_pattern: A string like "*.txt", which would find all text files.
    :return: A list=[] of absolute filepaths matching the glob pattern.
    '''
    matches = []
    names = []
    for root, dirnames, filenames in os.walk(directoryname):
        for filename in fnmatch.filter(filenames, glob_pattern):
            absolute_filepath = os.path.join(root, filename)
            matches.append(absolute_filepath)

            # name = filename.rsplit('/StrawberryExotic/')[-1]
            # names.append(name)

    return matches, names


def align(exprZ, folder_expr):
    # within replicates alignment parameters
    Dw=2.5  # rt modulation [s]
    Gw=0.30  # gap penalty
    # do the alignment

    expr_list = []
    expr_dir = folder_expr
    for expr_code in exprZ:
        print('Aligning...'+expr_code)
        file_name = os.path.join(expr_dir, expr_code )
        expr = load_expr(file_name)
        expr_list.append(expr)
    F1 = exprl2alignment(expr_list)
    print(F1)
    T1 = PairwiseAlignment(F1, Dw, Gw)
    print(T1)
    # A1 = align_with_tree(T1, min_peaks=2)
    # A1.write_csv('/home/cocopalacelove/Desktop/StrawberryExotic/output/alex_rt.csv', '/home/cocopalacelove/Desktop/StrawberryExotic/output/alex_area.csv')
    #

def main():
    folder_expr = '/home/cocopalacelove/Desktop/StrawberryExotic/output'


    print("Welcome to Aligner, ")
    #input_var = input(" Select sample group, enter specific characters that represent your desired sample: ")

    list_of_expr, names = glob(glob_pattern='*Alexandria*', directoryname=folder_expr)

    print list_of_expr

    align(list_of_expr, folder_expr)
    print('done')

if __name__ == "__main__":
    main()
@connerCpowell
Copy link
Author

@ma-bio21 @SiggiSmara

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant