Skip to main content

A very simple DTASelect-Filter.txt parser.

Project description

example workflow example workflow

filterframes

filterframes is a Python package that provides an easy way to parse and manipulate DTASelect filter files using pandas. The package allows you to read DTASelect-filter.txt files, create peptide and protein dataframes, modify the dataframes, and write the modified dataframes back to a new DTASelect-filter.txt file.

Note on dataframe columns:

The column names in the peptide and protein dataframes will correspond to the header lines in the DTASelect-filter.txt files. In order to edit and output a valid DTASelect-filter file you must ensure that the peptide and protein dataframe column names and order are conserved, and that no additional columns are included. Any changes in the columns order or names will be reflected in the output DTASelect-filter.txt file.

Installation

You can install filterframes using pip:

pip install filterframes

You can also install filterframes locally:

git clone https://github.com/pgarrett-scripps/FilterFrames.git
cd filterframes
pip install .

Usage

Here are some basic examples of how to use the package:

Example Python Script:

from filterframes import from_dta_select_filter, to_dta_select_filter

# Read DTASelect-filter.txt file and create peptide and protein dataframes
file_input = r'tests/data/DTASelect-filter_V2_1_12_paser.txt'
header_lines, peptide_df, protein_df, end_lines = from_dta_select_filter(file_input)

# Display the first 5 rows of the peptide and protein dataframes
print("Peptide DataFrame:")
print(peptide_df.head())
print("\nProtein DataFrame:")
print(protein_df.head())

# Modify peptide or protein dataframes as needed (e.g., filtering, normalization, etc.)
# ...

# Write modified peptide and protein dataframes back to a DTASelect-filter.txt file
file_output = r'tests/data/DTASelect-filter_V2_1_12_paser.out.txt'
with open(file_output, 'w') as f:
    output_string_io = to_dta_select_filter(header_lines, peptide_df, protein_df, end_lines)
    f.write(output_string_io.getvalue())

print(f"\nModified DTASelect-filter.txt file saved to {file_output}")

Example Streamlit App:

# app.py
from io import StringIO

import streamlit as st
from filterframes import from_dta_select_filter, to_dta_select_filter

uploaded_filter_file = st.file_uploader("Choose a DTASelect-filter.txt file", type="txt")

if uploaded_filter_file:
    header_lines, peptide_df, protein_df, end_lines = from_dta_select_filter(StringIO(uploaded_filter_file.getvalue().decode('utf-8')))
    
    st.header('Peptide df')
    st.dataframe(peptide_df)
    st.header('Protein df')
    st.dataframe(protein_df)

    # Modify peptide or protein dataframes as needed (e.g., filtering, normalization, etc.)
    # ...

    io = to_dta_select_filter(header_lines, peptide_df, protein_df, end_lines)

    st.download_button(label="Download Filter",
                       data=io.getvalue(),
                       file_name="DTASelect-filter.txt",
                       mime="text/plain")

Functions

The main functions provided by the package are:

from_dta_select_filter(file_input: Union[str, TextIOWrapper, StringIO]) -> Tuple[List[str], pd.DataFrame, pd.DataFrame, List[str]]

Reads a DTASelect-filter.txt file and returns header lines, peptide dataframe, protein dataframe, and end lines.

to_dta_select_filter(header_lines: List[str], peptide_df: pd.DataFrame, protein_df: pd.DataFrame, end_lines: List[str]) -> StringIO

Writes the given header lines, peptide dataframe, protein dataframe, and end lines to a StringIO object in the DTASelect-filter.txt format.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filterframes-0.1.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

filterframes-0.1.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file filterframes-0.1.3.tar.gz.

File metadata

  • Download URL: filterframes-0.1.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for filterframes-0.1.3.tar.gz
Algorithm Hash digest
SHA256 b67ebd300a58a84aad667d8bf3a5a5b9bfbe221e835d285cb8fc6b9e77798821
MD5 a843a07dce3490a5af3bb249ae5d4e00
BLAKE2b-256 c0f081f03a4324fd8ba138280ce70496d273b84bad97b5351684b0195a5443d3

See more details on using hashes here.

File details

Details for the file filterframes-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for filterframes-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 269c151eef2d7af0a8d78033ee1955736e067bd03be75f03302090d365e6615e
MD5 2fa1a4ffd3d26c5c13b008e735e482e6
BLAKE2b-256 5b2161cdabca8e443e2f6e4f6200febeb52f4bc4111e288f1e7939ae9e7d5889

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page