-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #253 from joaomcteixeira/2_user_defined_cara_deriv…
…es_pkls Added 3 user peaklist formats
- Loading branch information
Showing
18 changed files
with
531 additions
and
104 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 @@ | ||
1 10.494 0.000 H 3 | ||
2 130.175 0.000 N 3 | ||
4 9.965 0.000 H 4 | ||
5 125.165 0.000 N 4 | ||
7 9.748 0.000 H 5 | ||
8 123.874 0.000 N 5 | ||
10 9.978 0.000 H 1 | ||
11 121.313 0.000 N 1 |
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,34 @@ | ||
loop_ | ||
_Atom_shift_assign_ID | ||
_Residue_seq_code | ||
_Residue_label | ||
_Atom_name | ||
_Atom_type | ||
_Chem_shift_value | ||
_Chem_shift_value_error | ||
_Chem_shift_ambiguity_code | ||
|
||
1 181 CYS C C 174.365 0.3 1 | ||
2 181 CYS CA C 57.746 0.3 1 | ||
3 181 CYS CB C 43.369 0.3 1 | ||
4 181 CYS H H 9.977 0.020 1 | ||
5 181 CYS N N 121.339 0.3 1 | ||
6 183 VAL C C 177.016 0.3 1 | ||
7 183 VAL CA C 65.287 0.3 1 | ||
8 183 VAL CB C 31.942 0.3 1 | ||
9 183 VAL H H 8.155 0.020 1 | ||
10 183 VAL N N 121.041 0.3 1 | ||
11 184 ASN CA C 57.382 0.3 1 | ||
12 184 ASN H H 8.944 0.020 1 | ||
13 184 ASN N N 116.914 0.3 1 | ||
14 185 TRP C C 176.036 0.3 1 | ||
15 185 TRP CA C 57.791 0.3 1 | ||
16 185 TRP CB C 29.590 0.3 1 | ||
17 185 TRP H H 8.641 0.020 1 | ||
18 185 TRP N N 121.241 0.3 1 | ||
19 186 VAL C C 174.765 0.3 1 | ||
20 186 VAL CA C 61.880 0.3 1 | ||
21 186 VAL CB C 35.364 0.3 1 | ||
22 186 VAL H H 9.920 0.020 1 | ||
23 186 VAL N N 120.580 0.3 1 | ||
stop_ |
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,5 @@ | ||
Peak,Region,Type,Index (F2),Index (F1),?(F2) [ppm],?(F1) [ppm],?(F2) [Hz],?(F1) [Hz],Intensity [abs],Annotation, | ||
35,1,Automatic,339.3,1183.7,8.8003,118.7829,5279.5636,7220.8575,364636.02,A1, | ||
12,1,Automatic,246.7,464.4,9.3439,126.0890,5605.6855,7664.9981,166196.66,F2, | ||
16,1,Automatic,363.3,1559.3,8.6594,114.9676,5195.0334,6988.9240,196764.84,V3, | ||
22,1,Automatic,303.2,160.8,9.0119,129.1727,5406.5087,7852.4574,230523.44,W4, |
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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
# official formats | ||
from core.fslibs.parsing_routines.ansig import parse_ansig_peaklist as ansig | ||
from core.fslibs.parsing_routines.ccpnmrv2 import parse_ccpnmrv2_peaklist as ccpnmrv2 | ||
from core.fslibs.parsing_routines.nmrdraw import parse_nmrdraw_peaklist as nmrdraw | ||
from core.fslibs.parsing_routines.nmrview import parse_nmrview_peaklist as nmrview | ||
from core.fslibs.parsing_routines.sparky import parse_sparky_peaklist as sparky | ||
# user defined formats | ||
from core.fslibs.parsing_routines.user_defined_1 import parse_user_peaklist_1 as user_pkl_1 | ||
from core.fslibs.parsing_routines.user_defined_2 import parse_user_peaklist_2 as user_pkl_2 | ||
from core.fslibs.parsing_routines.user_defined_3 import parse_user_peaklist_3 as user_pkl_3 | ||
#from core.fslibs.parsing_routines.YOUR_FILE import parse_YOUR_FORMAT_peaklist as YOUR_FORMAT |
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,111 @@ | ||
""" | ||
Copyright © 2017-2018 Farseer-NMR | ||
Teixeira, J.M.C., Skinner, S.P., Arbesú, M. et al. J Biomol NMR (2018). | ||
https://doi.org/10.1007/s10858-018-0182-5 | ||
João M.C. Teixeira and Simon P. Skinner | ||
@ResearchGate https://goo.gl/z8dPJU | ||
@Twitter https://twitter.com/farseer_nmr | ||
This file is part of Farseer-NMR. | ||
Farseer-NMR is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Farseer-NMR is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Farseer-NMR. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
from core.fslibs.Peak import Peak | ||
from core.utils import eval_str_to_float | ||
from core.fslibs import wet as fsw | ||
|
||
def parse_user_peaklist_1(peaklist_file): | ||
""" | ||
Parses a user defined CARA-derived peaklist. | ||
File extention: *.prot | ||
Peaklist format: | ||
1 10.494 0.000 H 238 | ||
2 130.175 0.000 N 238 | ||
4 9.965 0.000 H 216 | ||
5 125.165 0.000 N 216 | ||
In the current version, only H and N atoms are considered. | ||
Returns: | ||
a list fo Peak objects. | ||
""" | ||
|
||
fin = open(peaklist_file, 'r') | ||
peakList = [] | ||
|
||
current_residue = None | ||
count_residue = 0 | ||
|
||
counter = -1 | ||
|
||
eval_elements = [ | ||
str.isdigit, | ||
eval_str_to_float, | ||
eval_str_to_float, | ||
str.isalpha, | ||
str.isdigit | ||
] | ||
|
||
for line in fin: | ||
counter += 1 | ||
|
||
ls = line.strip().split() | ||
|
||
if not ls: | ||
continue | ||
|
||
elif all([f(e) for e, f in zip(ls, eval_elements)]) \ | ||
and len(ls) == 5: | ||
pass | ||
|
||
else: | ||
msg = "The peaklist {} contains a wrong line format in line {}."\ | ||
.format(peaklist_file, counter) | ||
print(fsw.gen_wet('ERROR', msg, 29)) | ||
fsw.abort() | ||
|
||
if ls[3] not in ('N', 'H'): | ||
continue | ||
|
||
if ls[-1] != current_residue: | ||
current_residue = ls[-1] | ||
position = [ls[1]] | ||
atom = [ls[3]] | ||
count_residue += 1 | ||
|
||
elif ls[-1] == current_residue: | ||
position.append(ls[1]) | ||
atom.append(ls[3]) | ||
|
||
peak = Peak( | ||
peak_number=count_residue, | ||
positions=position, | ||
residue_number=current_residue, | ||
residue_type=None, | ||
atoms=atom, | ||
linewidths=[0, 0], | ||
volume=0, | ||
height=0, | ||
format_='user_pkl_1' | ||
) | ||
|
||
peakList.append(peak) | ||
|
||
fin.close() | ||
|
||
return peakList |
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,96 @@ | ||
""" | ||
Copyright © 2017-2018 Farseer-NMR | ||
Teixeira, J.M.C., Skinner, S.P., Arbesú, M. et al. J Biomol NMR (2018). | ||
https://doi.org/10.1007/s10858-018-0182-5 | ||
João M.C. Teixeira and Simon P. Skinner | ||
@ResearchGate https://goo.gl/z8dPJU | ||
@Twitter https://twitter.com/farseer_nmr | ||
This file is part of Farseer-NMR. | ||
Farseer-NMR is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Farseer-NMR is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Farseer-NMR. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
from core.fslibs.Peak import Peak | ||
|
||
def parse_user_peaklist_2(peaklist_file): | ||
""" | ||
Parses a CARA peaklist. | ||
File extention: *.str | ||
Peaklist format: | ||
loop_ | ||
_Atom_shift_assign_ID | ||
_Residue_seq_code | ||
_Residue_label | ||
_Atom_name | ||
_Atom_type | ||
_Chem_shift_value | ||
_Chem_shift_value_error | ||
_Chem_shift_ambiguity_code | ||
1 181 CYS C C 174.365 0.3 1 | ||
2 181 CYS CA C 57.746 0.3 1 | ||
3 181 CYS CB C 43.369 0.3 1 | ||
4 181 CYS H H 9.977 0.020 1 | ||
In the current version, only H and N atoms are considered. | ||
Returns: | ||
a list fo Peak objects. | ||
""" | ||
fin = open(peaklist_file, 'r') | ||
peakList = [] | ||
|
||
current_residue = None | ||
residue_counter = 0 | ||
|
||
for line in fin: | ||
if not line.strip() \ | ||
or line.strip().startswith('_') \ | ||
or line.strip().endswith('_'): | ||
continue | ||
|
||
ls = line.strip().split() | ||
|
||
if ls[3] not in ('N', 'H'): | ||
continue | ||
|
||
if ls[1] != current_residue: | ||
current_residue = ls[1] | ||
positions = [ls[5]] | ||
atom = [ls[3]] | ||
residue_counter += 1 | ||
|
||
elif ls[1] == current_residue: | ||
positions.append(ls[5]) | ||
atom.append(ls[3]) | ||
|
||
peak = Peak( | ||
peak_number=residue_counter, | ||
positions=positions, | ||
residue_type=ls[2], | ||
residue_number=ls[1], | ||
atoms=atom, | ||
linewidths=[0, 0], | ||
volume=0, | ||
height=0, | ||
format_='user_pkl_2' | ||
) | ||
|
||
peakList.append(peak) | ||
|
||
fin.close() | ||
return peakList |
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,62 @@ | ||
""" | ||
YOUR DESCRIPTION HERE | ||
To add your parsing routine, you sould: | ||
1) code your funcion in this file | ||
2) add a import statment in the __init__.py file according to the | ||
given examples. | ||
3) code the identification snipet in core.fslibs.parsing.get_peaklist_format() | ||
Add, if necessary, a file extention to the list: | ||
core.fslibs.parsing.file_extensions | ||
4) if your peaklist requires a FASTA file to read residue types, add your | ||
peaklist format code (defined in 3) in the list: | ||
core.fslibs.setup_farseer_calculation.peaklist_format_requires_fasta | ||
""" | ||
from core.fslibs.Peak import Peak | ||
from core.utils import aal1tol3 | ||
|
||
def parse_user_peaklist_3(peaklist_file): | ||
""" | ||
Parses YOUR FORMAT peaklist. | ||
According to the format: | ||
* paste an example of your format here* | ||
Parameters: | ||
- peaklist_file (str): path to peaklist | ||
Returns: | ||
peakList (list): a list of Peak objects. | ||
""" | ||
fin = open(peaklist_file, 'r') | ||
peakList = [] | ||
|
||
|
||
for line in fin: | ||
|
||
ls = line.strip().rstrip(',').split(',') | ||
|
||
if not line.strip() or not ls[0].isdigit(): | ||
continue | ||
|
||
pk = Peak( | ||
peak_number=ls[0], | ||
positions=ls[5:7], | ||
atoms=['H','N'], | ||
residue_type=aal1tol3[ls[-1][0]], | ||
residue_number=ls[-1][1:], | ||
linewidths=ls[7:9], | ||
height=ls[9], | ||
volume=ls[9], | ||
details=ls[2], | ||
format_='user_pkl_3' | ||
) | ||
|
||
peakList.append(pk) | ||
|
||
else: | ||
fin.close() | ||
|
||
return peakList |
Oops, something went wrong.