-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
280 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
|
||
# Outputs | ||
smiles_output.txt | ||
|
||
# vscode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Brenda Ferrari | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pandas as pd | ||
|
||
class Dataframe: | ||
"""A class that represents dataframe manipulation | ||
Methods: | ||
create_dataframe(self, columns): Return a formated dataframe""" | ||
|
||
def __init__(self, data): | ||
"""Initialize the instance of a class. | ||
Arguments: | ||
data(dict): data used to transform smiles code to peptide code.""" | ||
self._data = data | ||
|
||
@property | ||
def data(self): | ||
"""Data used to manipulate dataframe.""" | ||
return self._data | ||
|
||
def create_dataframe(self, columns): | ||
"""Return a formated dataframe. | ||
Arguments: | ||
columns(list): list of strings with column names.""" | ||
result = pd.DataFrame.from_dict(self.data, orient='index', columns=columns) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pandas as pd | ||
|
||
|
||
class Dictionary: | ||
""" A class that represents the dictionary functionalities. | ||
Method: | ||
Dict(self, one_code=False, three_code=False): Return the full dictionary with all data regards aminoacids on the database. | ||
""" | ||
|
||
def Dict(self, one_code=False, three_code=False): | ||
"""Return the full dictionary with all data regards aminoacids on the database. | ||
Arguments: | ||
one_code=False: Default is False. If true returns the one letter code of aminoacids | ||
three_code=False: Default is False. If true returns the three letter code of aminoacids | ||
""" | ||
|
||
if one_code is True: | ||
dictio = pd.read_csv("resources/codes.csv", sep=' ', names=['name', 'smiles', '3lcode', '1lcode'], | ||
usecols= ['smiles', '1lcode'], index_col=0, header=None, squeeze=True).to_dict() | ||
|
||
elif three_code is True: | ||
dictio = pd.read_csv("resources/codes.csv", sep=' ', names=['name', 'smiles', '3lcode', '1lcode'], | ||
usecols= ['smiles', '3lcode'], index_col=0, header=None, squeeze=True).to_dict() | ||
|
||
return dictio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
class PeptoCode: | ||
"""A class that represents peptide to code functionalities. | ||
Arguments: | ||
smiles(str): smiles strings to convert to peptide code. | ||
peptide_data(dict): data used to transform smiles code to peptide code. | ||
Methods: | ||
count_and_change(self): Return a string with the aminoacid code.""" | ||
|
||
def __init__(self, smiles, peptide_data): | ||
"""Initialize the instance of a class. | ||
Arguments: | ||
smiles(str): smiles strings to convert to peptide code. | ||
peptide_data(dict): data used to transform smiles code to peptide code.""" | ||
self.smiles = smiles | ||
self._peptide_data = peptide_data | ||
|
||
@property | ||
def peptide_data(self): | ||
"""Data used to transform smiles code to peptide code.""" | ||
return self._peptide_data | ||
|
||
def count_and_change(self): | ||
"""Return a string with the aminoacid code.""" | ||
|
||
aacode = [] | ||
notaaCode = [] | ||
i = 0 | ||
|
||
while i < len(self.smiles): | ||
keys = list(self.peptide_data.keys()) | ||
|
||
for j in range(len(keys)): | ||
key = keys[j] | ||
|
||
sub = self.smiles[i:i+len(key)] | ||
if sub in self.peptide_data: | ||
i = i + len(key) | ||
aacode.append(self.peptide_data[sub]) | ||
break | ||
|
||
if j == len(self.peptide_data.keys())-1: | ||
notaaCode.append(sub) | ||
i = i + 1 | ||
i = i + len(key) | ||
aacode.append('*') | ||
|
||
code = ''.join(aacode) | ||
|
||
return code, notaaCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from functionalities.peptocode import PeptoCode | ||
from functionalities.dataframe import Dataframe | ||
from functionalities.dictionary import Dictionary | ||
|
||
import pandas as pd | ||
import sys | ||
|
||
if len(sys.argv) <= 1: | ||
print("One parameter is missing. Please add input file name at following manner: 'python main.py one_code=True/three_code=True'") | ||
sys.exit() | ||
|
||
one_code = sys.argv[1].lower() == 'true' | ||
three_code = sys.argv[2].lower() == 'true' | ||
|
||
print('Do you wish to transform one aminoacid of a file? Type a to one aminoacid or b for a file.') | ||
answer = input() | ||
if answer.lower() == "a": | ||
print() | ||
smiles = input('Type your peptide smiles: ') | ||
|
||
dictio = Dictionary() | ||
|
||
peptocode = PeptoCode(smiles, dictio.Dict(one_code, three_code)) | ||
aacode, notaaCode = peptocode.count_and_change() | ||
|
||
if aacode != "*": | ||
print(f"Your code is: {aacode}") | ||
if notaaCode: | ||
print(f"Some codes were not recognized: {notaaCode}") | ||
else: | ||
print(f"All codes were analyzed and recognized.") | ||
else: | ||
print("Unfortunately your code could not be recognized. Please, verify your code or contact the developers.") | ||
|
||
elif answer.lower() == "b": | ||
smiles = input('Type your file name with path: ') | ||
|
||
dictio = Dictionary() | ||
|
||
df = pd.read_csv(smiles) | ||
aacode = [] | ||
notaaCode = [] | ||
aasmiles = [] | ||
countlen = [] | ||
count = 0 | ||
for row in df.itertuples(): | ||
aasmiles.append(row[1]) | ||
|
||
peptocode = PeptoCode(row[1], dictio.Dict(one_code, three_code)) | ||
code, notCode = peptocode.count_and_change() | ||
aacode.append(code) | ||
notaaCode.append(notCode) | ||
|
||
count += 1 | ||
countlen.append(count) | ||
|
||
variables = zip(aasmiles, aacode, notaaCode) | ||
variablesDataframe = dict(zip(countlen, variables)) | ||
|
||
dataframe = Dataframe(variablesDataframe) | ||
data = dataframe.create_dataframe(columns=('smiles', 'code', 'not recognized')) | ||
data.to_csv('smiles_output.txt') | ||
|
||
if aacode != "*": | ||
print("smiles_output.txt was saved successfully.") | ||
if notaaCode: | ||
print(f"Some codes were not recognized: {notaaCode}") | ||
else: | ||
print(f"All codes were analyzed and recognized.") | ||
else: | ||
print("Unfortunately your code could not be recognized. Please, verify your code or contact the developers.") |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
python>=3.6.13 | ||
pandas>=1.1.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
smiles | ||
N[C@@]([H])(CCCNC(=N)N)C(=O)N[C@@]([H])([C@]([H])(O)C)C(=O)N[C@@]([H])(CCCCN)C(=O)N[C@@]([H])(CCCNC(=N)N)C(=O)O | ||
N[C@@]([H])(CCCNC(=N)N)C(=O)N[C@@]([H])([C@]([H])(O)C)C(=O)N[C@@]([H])(CCCCN)C(=O)N[C@@]([H])(CCCNC(=N)N)C(=O)O | ||
N[C@@]([H])(CCCNC(=N)N)C(=O)N[C@@]([H])([C@]([H])(O)C)C(=O)N[C@@]([H])(CCCCN)C(=O)N[C@@]([H])(CCCNC(=N)N)C(=O)O | ||
N[C@@]([H])(CCCNC(=N)N)C(=O)N[C@@]([H])([C@]([H])(O)C)C(=O)N[C@@]([H])(CCCCN)C(=O)N[C@@]([H])(CCCNC(=N)N)C(=O)O | ||
N[C@@]([H])(CCCNC(=N)N)C(=O)N[C@@]([H])([C@]([H])(O)C)C(=O)N[C@@]([H])(CCCCN)C(=O)N[C@@]([H])(CCCNC(=N)N)C(=O)O |