Skip to content

Commit 0c3a9c5

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 63b5637 + 5c88b02 commit 0c3a9c5

File tree

11 files changed

+280
-56
lines changed

11 files changed

+280
-56
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
4+
# Outputs
5+
smiles_output.txt
6+
7+
# vscode
8+
.vscode

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Brenda Ferrari
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

README.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,60 @@
1-
# PepToCodes - Peptides to Codes
1+
# PepToCodes (1.0.0) - Peptides to Codes
22

3-
Script developed to transform the amino acid smiles to one letter code or three letter code for latter analysis
3+
Script developed to transform the amino acid smiles to one letter code or three letter code for later analysis.
44

55
<img src="resources/images/Peptocodes.png" width="570">
66

77
*Illustrative image*
88

9-
## How to use
9+
## Requirements
1010

11-
* Download the code and unzip it on the desirable directory
11+
* [pandas](https://pandas.pydata.org/) - a Python package that provides fast, flexible, and expressive data structures designed to make working with "relational" or "labeled" data both easy and intuitive.
12+
13+
Libraries were used in a [Miniconda3](https://docs.conda.io/en/latest/miniconda.html) environment using python 3.6.13
14+
15+
## Instalation
1216

13-
To run use the following command:
17+
Miniconda3: [Installation](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)
18+
19+
pandas:
1420
```
15-
python peptocodes.py
21+
conda install -c anaconda pandas
1622
```
1723

18-
* Type your peptide smiles as an input
24+
## How to use
1925

20-
i.e. 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
26+
* Download the code and unzip it on the desirable directory
2127

22-
* The answer will pop-up at your terminal screen
28+
* To obtain the one letter code use True as first argument and to obtain the three letter code use True as second argument
2329

24-
i.e. RTKR
30+
* To obtain one letter code:
31+
32+
```
33+
python main.py True False
34+
```
2535
26-
## Observations
36+
* To obtain three letter code:
37+
38+
```
39+
python main.py False True
40+
```
2741
28-
* In this version you may also obtain the 3 letter code for your smiles, just change line 10 to:
29-
```
30-
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()
31-
```
42+
* For one aminoacid analysis:
43+
44+
* Type your peptide smiles as an input
45+
46+
i.e. 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
47+
48+
* The answer will pop-up at your terminal screen
49+
50+
i.e. RTKR
51+
52+
* For more than one aminoacid analysis:
53+
54+
* Use the file [smiles.txt](resources/smiles.txt) as example on how to format input data
55+
56+
* Asteriscs in your code answer means the software could not recognize the input. Please, keep in mind that this software only recognizes [20 aminoacids](resources/codes.csv) for now (canonical and isomeric). We are working on implementing a bigger database.
3257
33-
* **In this version is only possible to tranform ONE smiles at a time**
3458
3559
## Authorship
3660

functionalities/dataframe.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pandas as pd
2+
3+
class Dataframe:
4+
"""A class that represents dataframe manipulation
5+
6+
Methods:
7+
create_dataframe(self, columns): Return a formated dataframe"""
8+
9+
def __init__(self, data):
10+
"""Initialize the instance of a class.
11+
12+
Arguments:
13+
data(dict): data used to transform smiles code to peptide code."""
14+
self._data = data
15+
16+
@property
17+
def data(self):
18+
"""Data used to manipulate dataframe."""
19+
return self._data
20+
21+
def create_dataframe(self, columns):
22+
"""Return a formated dataframe.
23+
24+
Arguments:
25+
columns(list): list of strings with column names."""
26+
result = pd.DataFrame.from_dict(self.data, orient='index', columns=columns)
27+
return result

functionalities/dictionary.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pandas as pd
2+
3+
4+
class Dictionary:
5+
""" A class that represents the dictionary functionalities.
6+
7+
Method:
8+
Dict(self, one_code=False, three_code=False): Return the full dictionary with all data regards aminoacids on the database.
9+
"""
10+
11+
def Dict(self, one_code=False, three_code=False):
12+
"""Return the full dictionary with all data regards aminoacids on the database.
13+
14+
Arguments:
15+
one_code=False: Default is False. If true returns the one letter code of aminoacids
16+
three_code=False: Default is False. If true returns the three letter code of aminoacids
17+
"""
18+
19+
if one_code is True:
20+
dictio = pd.read_csv("resources/codes.csv", sep=' ', names=['name', 'smiles', '3lcode', '1lcode'],
21+
usecols= ['smiles', '1lcode'], index_col=0, header=None, squeeze=True).to_dict()
22+
23+
elif three_code is True:
24+
dictio = pd.read_csv("resources/codes.csv", sep=' ', names=['name', 'smiles', '3lcode', '1lcode'],
25+
usecols= ['smiles', '3lcode'], index_col=0, header=None, squeeze=True).to_dict()
26+
27+
return dictio

functionalities/peptocode.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
class PeptoCode:
2+
"""A class that represents peptide to code functionalities.
3+
4+
Arguments:
5+
smiles(str): smiles strings to convert to peptide code.
6+
peptide_data(dict): data used to transform smiles code to peptide code.
7+
8+
Methods:
9+
count_and_change(self): Return a string with the aminoacid code."""
10+
11+
def __init__(self, smiles, peptide_data):
12+
"""Initialize the instance of a class.
13+
14+
Arguments:
15+
smiles(str): smiles strings to convert to peptide code.
16+
peptide_data(dict): data used to transform smiles code to peptide code."""
17+
self.smiles = smiles
18+
self._peptide_data = peptide_data
19+
20+
@property
21+
def peptide_data(self):
22+
"""Data used to transform smiles code to peptide code."""
23+
return self._peptide_data
24+
25+
def count_and_change(self):
26+
"""Return a string with the aminoacid code."""
27+
28+
aacode = []
29+
notaaCode = []
30+
i = 0
31+
32+
while i < len(self.smiles):
33+
keys = list(self.peptide_data.keys())
34+
35+
for j in range(len(keys)):
36+
key = keys[j]
37+
38+
sub = self.smiles[i:i+len(key)]
39+
if sub in self.peptide_data:
40+
i = i + len(key)
41+
aacode.append(self.peptide_data[sub])
42+
break
43+
44+
if j == len(self.peptide_data.keys())-1:
45+
notaaCode.append(sub)
46+
i = i + 1
47+
i = i + len(key)
48+
aacode.append('*')
49+
50+
code = ''.join(aacode)
51+
52+
return code, notaaCode

main.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
from functionalities.peptocode import PeptoCode
2+
from functionalities.dataframe import Dataframe
3+
from functionalities.dictionary import Dictionary
4+
5+
import pandas as pd
6+
import sys
7+
8+
if len(sys.argv) <= 1:
9+
print("One parameter is missing. Please add input file name at following manner: 'python main.py one_code=True/three_code=True'")
10+
sys.exit()
11+
12+
one_code = sys.argv[1].lower() == 'true'
13+
three_code = sys.argv[2].lower() == 'true'
14+
15+
print('Do you wish to transform one aminoacid of a file? Type a to one aminoacid or b for a file.')
16+
answer = input()
17+
if answer.lower() == "a":
18+
print()
19+
smiles = input('Type your peptide smiles: ')
20+
21+
dictio = Dictionary()
22+
23+
peptocode = PeptoCode(smiles, dictio.Dict(one_code, three_code))
24+
aacode, notaaCode = peptocode.count_and_change()
25+
26+
if aacode != "*":
27+
print(f"Your code is: {aacode}")
28+
if notaaCode:
29+
print(f"Some codes were not recognized: {notaaCode}")
30+
else:
31+
print(f"All codes were analyzed and recognized.")
32+
else:
33+
print("Unfortunately your code could not be recognized. Please, verify your code or contact the developers.")
34+
35+
elif answer.lower() == "b":
36+
smiles = input('Type your file name with path: ')
37+
38+
dictio = Dictionary()
39+
40+
df = pd.read_csv(smiles)
41+
aacode = []
42+
notaaCode = []
43+
aasmiles = []
44+
countlen = []
45+
count = 0
46+
for row in df.itertuples():
47+
aasmiles.append(row[1])
48+
49+
peptocode = PeptoCode(row[1], dictio.Dict(one_code, three_code))
50+
code, notCode = peptocode.count_and_change()
51+
aacode.append(code)
52+
notaaCode.append(notCode)
53+
54+
count += 1
55+
countlen.append(count)
56+
57+
variables = zip(aasmiles, aacode, notaaCode)
58+
variablesDataframe = dict(zip(countlen, variables))
59+
60+
dataframe = Dataframe(variablesDataframe)
61+
data = dataframe.create_dataframe(columns=('smiles', 'code', 'not recognized'))
62+
data.to_csv('smiles_output.txt')
63+
64+
if aacode != "*":
65+
print("smiles_output.txt was saved successfully.")
66+
if notaaCode:
67+
print(f"Some codes were not recognized: {notaaCode}")
68+
else:
69+
print(f"All codes were analyzed and recognized.")
70+
else:
71+
print("Unfortunately your code could not be recognized. Please, verify your code or contact the developers.")

peptocodes.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
python>=3.6.13
2+
pandas>=1.1.5

resources/codes.csv

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,41 @@ Serine N[C@@]([H])(CO)C(=O) Ser S
1717
Threonine N[C@@]([H])([C@]([H])(O)C)C(=O) Thr T
1818
Tryptophan N[C@@]([H])(CC(=CN2)C1=C2C=CC=C1)C(=O) Trp W
1919
Tyrosine N[C@@]([H])(Cc1ccc(O)cc1)C(=O) Tyr Y
20-
Valine N[C@@]([H])(C(C)C)C(=O) Val V
20+
Valine N[C@@]([H])(C(C)C)C(=O) Val V
21+
Arginine C(C[C@@H](C(=O)O)N)CN=C(N)N Arg R
22+
Asparagine C([C@@H](C(=O)O)N)C(=O)N Asn N
23+
Aspartate C([C@@H](C(=O)O)N)C(=O)O Asp D
24+
Cysteine C([C@@H](C(=O)O)N)S Cys C
25+
Glutamine C(CC(=O)N)[C@@H](C(=O)O)N Gln Q
26+
Glutamate C(CC(=O)O)[C@@H](C(=O)O)N Glu E
27+
Histidine C1=C(NC=N1)C[C@@H](C(=O)O)N His H
28+
Isoleucine CC[C@H](C)[C@@H](C(=O)O)N Ile I
29+
Leucine CC(C)C[C@@H](C(=O)O)N Leu L
30+
Lysine C(CCN)C[C@@H](C(=O)O)N Lys K
31+
Methionine CSCC[C@@H](C(=O)O)N Met M
32+
Phenylalanine C1=CC=C(C=C1)C[C@@H](C(=O)O)N Phe F
33+
Proline C1C[C@H](NC1)C(=O)O Pro P
34+
Serine C([C@@H](C(=O)O)N)O Ser S
35+
Threonine C[C@H]([C@@H](C(=O)O)N)O Thr T
36+
Tryptophan C1=CC=C2C(=C1)C(=CN2)C[C@@H](C(=O)O)N Trp W
37+
Tyrosine C1=CC(=CC=C1C[C@@H](C(=O)O)N)O Tyr Y
38+
Valine CC(C)[C@@H](C(=O)O)N Val V
39+
Alanine CC(C(=O)O)N Ala A
40+
Arginine C(CC(C(=O)O)N)CN=C(N)N Arg R
41+
Asparagine C(C(C(=O)O)N)C(=O)N Asn N
42+
Aspartate C(C(C(=O)O)N)C(=O)O Asp D
43+
Cysteine C(C(C(=O)O)N)S Cys C
44+
Glutamine C(CC(=O)N)C(C(=O)O)N Gln Q
45+
Glutamate C(CC(=O)O)C(C(=O)O)N Glu E
46+
Histidine C1=C(NC=N1)CC(C(=O)O)N His H
47+
Isoleucine CCC(C)C(C(=O)O)N Ile I
48+
Leucine CC(C)CC(C(=O)O)N Leu L
49+
Lysine C(CCN)CC(C(=O)O)N Lys K
50+
Methionine CSCCC(C(=O)O)N Met M
51+
Phenylalanine C1=CC=C(C=C1)CC(C(=O)O)N Phe F
52+
Proline C1CC(NC1)C(=O)O Pro P
53+
Serine C(C(C(=O)O)N)O Ser S
54+
Threonine CC(C(C(=O)O)N)O Thr T
55+
Tryptophan C1=CC=C2C(=C1)C(=CN2)CC(C(=O)O)N Trp W
56+
Tyrosine C1=CC(=CC=C1CC(C(=O)O)N)O Tyr Y
57+
Valine CC(C)C(C(=O)O)N Val V

resources/smiles.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
smiles
2+
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
3+
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
4+
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
5+
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
6+
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

0 commit comments

Comments
 (0)