def test_throughput(self): fasta_file = fixtures.get_test_data("phil-82-proteins.fasta") glycan_file = fixtures.get_test_data("IAV_matched_glycans.txt") db_file = self.setup_tempfile("") print(db_file) glycan_builder = TextFileGlycanHypothesisSerializer(glycan_file, db_file) glycan_builder.start() glycopeptide_builder = naive_glycopeptide.MultipleProcessFastaGlycopeptideHypothesisSerializer( fasta_file, db_file, glycan_builder.hypothesis_id, constant_modifications=constant_modifications, variable_modifications=variable_modifications, max_missed_cleavages=2) glycopeptide_builder.start() self.clear_file(db_file)
def test_extract_forward_backward(self): fasta_file = fixtures.get_test_data("yeast_glycoproteins.fa") glycan_file = self.setup_tempfile(simple_n_glycans) forward_db = self.setup_tempfile("") reverse_db = self.setup_tempfile("") glycan_builder = TextFileGlycanHypothesisSerializer(glycan_file, forward_db) glycan_builder.start() builder = naive_glycopeptide.MultipleProcessFastaGlycopeptideHypothesisSerializer( fasta_file, forward_db, 1) cnt = builder.extract_proteins() assert cnt == 251 glycan_builder = TextFileGlycanHypothesisSerializer(glycan_file, reverse_db) glycan_builder.start() rev_builder = naive_glycopeptide.ReversingMultipleProcessFastaGlycopeptideHypothesisSerializer( fasta_file, reverse_db, 1) cnt = rev_builder.extract_proteins() assert cnt == 251 fwd_prots = builder.query(serialize.Protein).all() rev_prots = rev_builder.query(serialize.Protein).all() for fx, rx in zip(fwd_prots, rev_prots): assert fx.name == rx.name assert len(fx.glycosylation_sites) == len(rx.glycosylation_sites)
import unittest import tempfile import os from glycan_profiling.test import fixtures from glycan_profiling.test.test_constrained_combinatorics import (FILE_SOURCE) from glycan_profiling.profiler import MzMLGlycanChromatogramAnalyzer, GeneralScorer from glycan_profiling.database.builder.glycan import CombinatorialGlycanHypothesisSerializer from glycan_profiling.serialize import AnalysisDeserializer agp_glycomics_mzml = fixtures.get_test_data( "AGP_Glycomics_20150930_06.deconvoluted.mzML") class GlycanProfilerConsumerTest(unittest.TestCase): def setup_tempfile(self, content): file_name = tempfile.mktemp() + '.tmp' open(file_name, 'w').write(content) return file_name def clear_file(self, path): open(path, 'wb').close() def _make_hypothesis(self): file_name = self.setup_tempfile(FILE_SOURCE) builder = CombinatorialGlycanHypothesisSerializer( file_name, file_name + '.db') builder.run() self.clear_file(file_name) return file_name + '.db'
def load_spectra(self): return list( ProcessedMzMLDeserializer( get_test_data("example_glycopeptide_spectra.mzML")))
import unittest import tempfile import os import glob import ms_peak_picker import ms_deisotope from ms_deisotope.output.mzml import ProcessedMzMLDeserializer from glycan_profiling.test import fixtures from glycan_profiling.profiler import SampleConsumer agp_glycomics_mzml = fixtures.get_test_data( "AGP_Glycomics_20150930_06.centroid.mzML") class SampleConsumerTest(unittest.TestCase): def build_args(self): ms1_peak_picking_args = {"transforms": []} msn_peak_picking_args = {"transforms": []} ms1_deconvolution_args = { "scorer": ms_deisotope.scoring.PenalizedMSDeconVFitter(35.0, 2.0), "max_missed_peaks": 1, "averagine": ms_deisotope.glycan, "truncate_after": SampleConsumer.MS1_ISOTOPIC_PATTERN_WIDTH, "ignore_below": SampleConsumer.MS1_IGNORE_BELOW } msn_deconvolution_args = {
import unittest import tempfile from glycan_profiling.serialize.hypothesis.peptide import Peptide, Protein, Glycopeptide from glycan_profiling.database.builder.glycopeptide import informed_glycopeptide from glycan_profiling.database.builder.glycan import ( CombinatorialGlycanHypothesisSerializer) from glycan_profiling import serialize from glycan_profiling.test import fixtures from glycan_profiling.test.test_constrained_combinatorics import FILE_SOURCE as GLYCAN_RULE_FILE_SOURCE MZID_PATH = fixtures.get_test_data("AGP_Proteomics2.mzid") class MzIdGlycopeptideTests(unittest.TestCase): def setup_tempfile(self, source): file_name = tempfile.mktemp() open(file_name, 'w').write(source) return file_name def clear_file(self, path): open(path, 'wb') def test_build_hypothesis(self): glycan_file = self.setup_tempfile(GLYCAN_RULE_FILE_SOURCE) mzid_path = MZID_PATH db_file = glycan_file + '.db'
def _get_instance(self): pairs = np.loadtxt(fixtures.get_test_data('numpairs.txt')) return target_decoy.NearestValueLookUp(map(list, pairs))
import unittest import tempfile import os from glycan_profiling.test import fixtures from glycan_profiling.test.test_constrained_combinatorics import ( FILE_SOURCE) from glycan_profiling.profiler import MzMLGlycanChromatogramAnalyzer, GeneralScorer from glycan_profiling.database.builder.glycan import CombinatorialGlycanHypothesisSerializer from glycan_profiling.serialize import AnalysisDeserializer agp_glycomics_mzml = fixtures.get_test_data( "AGP_Glycomics_20150930_06.deconvoluted.mzML") class GlycanProfilerConsumerTest(unittest.TestCase): def setup_tempfile(self, content): file_name = tempfile.mktemp() open(file_name, 'w').write(content) return file_name def clear_file(self, path): open(path, 'wb').close() def _make_hypothesis(self): file_name = self.setup_tempfile(FILE_SOURCE) builder = CombinatorialGlycanHypothesisSerializer( file_name, file_name + '.db')
import unittest import tempfile import os import glob import ms_peak_picker import ms_deisotope from ms_deisotope.output.mzml import ProcessedMzMLDeserializer import numpy as np from glycan_profiling.test import fixtures from glycan_profiling.profiler import SampleConsumer agp_glycomics_mzml = fixtures.get_test_data( "AGP_Glycomics_20150930_06.centroid.mzML") agp_glycproteomics_mzml = fixtures.get_test_data( "20150710_3um_AGP_001_29_30.mzML") agp_glycproteomics_mzml_reference = fixtures.get_test_data( "20150710_3um_AGP_001_29_30.preprocessed.mzML") class SampleConsumerBase(object): def make_output_directory(self): path = tempfile.mkdtemp() return path def cleanup(self, directory): files = glob.glob(os.path.join(directory, "*")) for f in files: try:
import unittest import tempfile from glycan_profiling.serialize.hypothesis.peptide import Peptide, Protein, Glycopeptide from glycan_profiling.database.builder.glycopeptide import informed_glycopeptide from glycan_profiling.database.builder.glycan import ( CombinatorialGlycanHypothesisSerializer) from glycan_profiling import serialize from glycan_profiling.test import fixtures from glycan_profiling.test.test_constrained_combinatorics import FILE_SOURCE as GLYCAN_RULE_FILE_SOURCE MZID_PATH = fixtures.get_test_data("AGP_Proteomics2.mzid") class MzIdGlycopeptideTests(unittest.TestCase): def setup_tempfile(self, source): file_name = tempfile.mktemp() + '.tmp' open(file_name, 'w').write(source) return file_name def clear_file(self, path): open(path, 'wb') def test_build_hypothesis(self): glycan_file = self.setup_tempfile(GLYCAN_RULE_FILE_SOURCE) mzid_path = MZID_PATH db_file = glycan_file + '.db' glycan_builder = CombinatorialGlycanHypothesisSerializer( glycan_file, db_file)
def load_spectra(self): return list(ProcessedMzMLDeserializer(get_test_data("example_glycopeptide_spectra.mzML")))
import unittest import tempfile import os import glob import ms_peak_picker import ms_deisotope from ms_deisotope.output.mzml import ProcessedMzMLDeserializer import numpy as np from glycan_profiling.test import fixtures from glycan_profiling.profiler import SampleConsumer agp_glycomics_mzml = fixtures.get_test_data("AGP_Glycomics_20150930_06.centroid.mzML") agp_glycproteomics_mzml = fixtures.get_test_data("20150710_3um_AGP_001_29_30.mzML") agp_glycproteomics_mzml_reference = fixtures.get_test_data("20150710_3um_AGP_001_29_30.preprocessed.mzML") class SampleConsumerBase(object): def make_output_directory(self): path = tempfile.mkdtemp() return path def cleanup(self, directory): files = glob.glob(os.path.join(directory, "*")) for f in files: try: os.remove(f) except OSError: