BALL 1.5.0
Loading...
Searching...
No Matches
NMRStarFile.h
Go to the documentation of this file.
1// -*- Mode: C++; tab-width: 2; -*-
2// vi: set ts=2:
3//
4
5#ifndef BALL_FORMAT_NMRSTARFILE_H
6#define BALL_FORMAT_NMRSTARFILE_H
7
8#ifndef BALL_FORMAT_CIFFILE_H
9# include <BALL/FORMAT/CIFFile.h>
10#endif
11
12#ifndef BALL_KERNEL_PROTEIN_H
13# include <BALL/KERNEL/protein.h>
14#endif
15
16#ifndef BALL_STRUCTURE_PEPTIDES_H
18#endif
19
20#include <vector>
21
22namespace BALL
23{
114 : public CIFFile
115 {
116 public:
117
118 // constant variables to denote unknown values
119 static const float FLOAT_VALUE_NA;
120 static const int INT_VALUE_NA;
121
123
129
136 {
137 public:
139
140 // saveframe name -- referenced in the sample_condition_label
141 // of the saveframe "assigned_chemical_shifts"
143 // Accoring to the NMRStarFile 2.1 documentation
144 // the first entry MUST BE "_Variable_type".
145 // This is why we are allowed to map per type :-)
146 vector<String> types;
150
151 bool hasType(String type) {return values.has(type);}
152 std::ostream& operator >> (std::ostream& s);
153 };
154
159 {
160 public:
161
167 {
168 public:
170 void clear();
171
178
179 std::ostream& operator >> (std::ostream& s);
180 };
181
183 void clear();
184
188 vector <Component> components;
189
190 std::ostream& operator >> (std::ostream& s);
191 };
192
215
222 {
223 public:
225
226 // The saveframe's name = set name
227 // can be referenced in the saveframe "assigned_chemical_shifts"
229 std::vector<ShiftReferenceElement> elements;
230
231 std::ostream& operator >> (std::ostream& s);
232 };
233
240 {
241 public:
243
252
253 bool operator == (const NMRAtomData& atom) const;
254 std::ostream& operator >> (std::ostream& s);
255 };
256
257
267 class BALL_EXPORT NMRAtomDataSet // _Saveframe_category assigned_chemical_shifts
268
269 {
270 public:
272
275 std::vector<NMRAtomData> atom_data;
278 std::vector<String> samples;
279
280 std::ostream& operator >> (std::ostream& s);
281
282 protected:
284 };
285
307
313 {
314 public:
317 {
318 public:
320
321 std::ostream& operator >> (std::ostream& s);
322 void clear();
323
332 };
333
334
336
344 // polymer residue sequence information
347 // we want to allow things like resid 137A, so we cannot use Index
348 // key: index -- value: aminoacidname
350 vector<HomologDB> homolog_database_entries;
351
352 std::ostream& operator >> (std::ostream& s);
353 void clear();
354 };
355
356
362 {
363 // System related information
364 public:
366 {
367 public:
369
370 std::ostream& operator >> (std::ostream& s);
371 void clear();
372
378 };
379
380
381 // Central class for convenience
383 {
384 public:
386 std::ostream& operator >> (std::ostream& s);
387 void clear();
388
393 };
394
395
398
399 ChemicalUnit const& getChemicalUnit(Position i) const { return chemical_units[i]; }
400 ChemicalUnit& getChemicalUnit(Position i) { return chemical_units[i]; }
401
402 Size getNumberOfChemicalUnits() const {return chemical_units.size(); }
403
404 // Name of the molecular system
407 vector<ChemicalUnit> chemical_units;
414 // related entries in various DB's
415 vector<RelatedDB> related_database_entries;
416
418
419 std::ostream& operator >> (std::ostream& s);
420 void clear();
421 };
422
423
429 {
430 public:
435
436 std::ostream& operator >> (std::ostream& s);
437 };
438
439
446 {
447 public:
448
455 //<saveframe_id, atom_id_in_nmr_atom_data_set>
456 typedef std::pair<Position, Position> BMRBIndex;
457 typedef std::map<Atom const* , BMRBIndex> BALLToBMRBMapping;
458 typedef std::map<const NMRAtomData*, Atom const*> BMRBToBALLMapping;
459 //TODO: Dont use pointer but something more sophisticated!
460
462
467
474 BALLToBMRBMapper(Chain const& chain, const NMRStarFile& nmr_data, const String& chemical_unit);
475
477 virtual ~BALLToBMRBMapper() {}
478
480
483
485 const Chain* getChain() const {return chain_;}
486
488 void setChain(Chain const& chain) { chain_ = &chain;
489 num_mismatches_ = -1;
490 num_gaps_ = -1;}
491
493 void setNMRStarFile(NMRStarFile const& nmrfile) {nmr_data_ = &nmrfile;
494 num_mismatches_ = -1;
495 num_gaps_ = -1;}
496
498 const NMRStarFile* getNMRStarFile() const {return nmr_data_;}
499
501 void setNMRAtomDataSet(NMRAtomDataSet const& nmr_atom_data_set){nmr_atom_data_set_= &nmr_atom_data_set;}
502
504 bool setNMRAtomDataSetByName(String const& chemical_unit_name);
505
506 // Get the NMRAtomDataSet
507 const NMRAtomDataSet* getNMRAtomDataSet() const{return nmr_atom_data_set_;}
508
510 BALLToBMRBMapping& getBALLToBMRBMapping() {return ball_to_bmrb_map_;}
511
513 const BALLToBMRBMapping& getBALLToBMRBMapping() const {return ball_to_bmrb_map_;}
514
516 BMRBToBALLMapping& getBMRBToBALLMapping() {return bmrb_to_ball_map_;}
517
519 const BMRBToBALLMapping& getBMRBToBALLMapping() const {return bmrb_to_ball_map_;}
520
522 int getNumberOfMismatches(){return num_mismatches_;}
523
525 int getNumberOfGaps(){return num_gaps_;}
526
528 bool isMapped(const NMRAtomData& nmr_atom) const;
529
535 const Atom* getBALLAtom(const NMRAtomData& nmr_atom) const;
536
541 bool isMapped(Atom const* atom) const;
542
544 BMRBIndex operator () (const Atom* atom);
545
553
563 bool createMapping(const String& aligned_ball_sequence,
564 const String& aligned_nmrstar_sequence);
565
568 void clear();
569
571
572 protected:
573
575
579
582
585
586 // NOTE: do *not* attempt to delete these pointers!
587 const Chain* chain_;
593 bool valid_;
595
596 private:
597 const Atom* findNMRAtom_(const NMRAtomData& atom) const;
598
599 };
600
602
605
609
614 NMRStarFile(const String& file_name, File::OpenMode open_mode = std::ios::in);
615
619
620
624
628 bool read();
629
630 /* Read an NMRStarFile and assign the shifts to the
631 given AtomContainer using a trivial standard mapping.
632 If the AtomContainer is a system, the first chain in chosen.
633
634 @param ac AtomContainer to which the NMRStarfile's shift should be assigned.
635 @return bool - <tt>true</tt> if reading the file was successful
636 */
637 //TODO to be able to use this function, further functions getMapping() and assign() are needed.
639
646 bool assignShifts(BALLToBMRBMapper& ball_to_bmrb_mapping);
647
660 const String& chemical_unit,
661 const String& aligned_ball_sequence,
662 const String& aligned_nmrstar_sequence);
663
667
670 Size getNumberOfShiftsAssigned() const {return number_of_assigned_shifts_;};
671
674 const std::vector<NMRAtomDataSet>& getNMRData() const;
675
678 const EntryInformation& getEntryInformation() const {return entry_information_;};
679
682 const MolecularSystem& getMolecularInformation() const {return molecular_system_;};
683
686 MolecularSystem& getMolecularInformation() {return molecular_system_;};
687
688
692
696
697
701
704 bool hasSampleCondition(String name) const;
705
709
713
715 SampleCondition& getSampleCondition(Position i) {return sample_conditions_[i];};
716
718 const SampleCondition& getSampleCondition(Position i) const {return sample_conditions_[i];};
719
721 Size getNumberOfSampleConditions() const {return sample_conditions_.size();};
722
724 const std::vector<SampleCondition>& getSampleConditions() const {return sample_conditions_;};
725
727 std::vector<SampleCondition>& getSampleConditions() {return sample_conditions_;};
728
729 // addSampleCondition TODO!!
730
732 std::vector<Sample> getSamples() const {return samples_;};
733 //const std::vector<Sample>& getSamples() const {return samples_;};
734
736 Size getNumberOfSamples() const {return samples_.size();};
737
739 bool hasSample(String label) const;
740
745
749 Sample getSample(String label) const;
750
752 std::vector<ShiftReferenceSet>& getShiftReferenceSets() {return shift_references_;};
754 const std::vector<ShiftReferenceSet>& getShiftReferenceSets() const {return shift_references_;};
755
757 Size getNumberOfShiftReferenceSets() const {return shift_references_.size();};
758
761
763 ShiftReferenceSet& getShiftReferenceSet(Position i) {return shift_references_[i];};
765 const ShiftReferenceSet& getShiftReferenceSet(Position i) const {return shift_references_[i];};
766
771
772
774 std::vector<NMRSpectrometer>& getNMRSpectrometers() {return nmr_spectrometers_;};
776 const std::vector<NMRSpectrometer>& getNMRSpectrometers() const {return nmr_spectrometers_;};
777
779 Size getNumberOfNMRSpectrometers() const {return nmr_spectrometers_.size();};
780
785
790
793
796
797
802
807
812
817
819 Size getNumberOfMonomericPolymers() const {return monomeric_polymers_.size();};
820
822 vector<MonomericPolymer> getMonomericPolymers() const {return monomeric_polymers_;};
823
825 bool hasMonomericPolymer(String name) const;
826
832 bool isMonomericPolymer(String chemical_unit_label);
833
837 //TODO: Store changes/additions as Saveframes also in CIFFile
839
840
850
852 bool hasHshifts() const {return has_H_shifts_;};
853
855 bool hasCshifts() const {return has_C_shifts_;};
856
858 bool hasNshifts() const {return has_N_shifts_;};
859
861
862
866
870 bool operator == (const NMRStarFile& f) const;
871
875 bool operator != (const NMRStarFile& f) const;
876
879 void clear();
880
882
883 private:
884
885 /*_ @name NMRStar file specific Help-Methods
886 */
887 //_@{
888
890 void readEntryInformation_();
891
893 void readMolSystem_();
894
896 void readMonomericPolymers_();
897
899 void readSampleConditions_();
900
902 void readShiftReferences_();
903
905 void readShifts_();
906
908 void readSamples_();
909
911 void readNMRSpectrometer_();
912
914 void findDependiencies_();
915
917 void setSpecialCharacters_(String characters);
918
920 bool isValidSingleValue_(String value);
921
923 float valueToFloat_(String value);
924
926 int valueToInt_(String value);
932 bool assignShifts_(BALLToBMRBMapper& pdb_to_bmrb_mapping);
933
934 //_@}
935 /*_ @name NMRStar file specific attributes
936 */
937 //_@{
938
939 /*_ A flag indicating validity of this instance. A sole NMRStarFile
940 instance cannot be valid, because it does not have any information.
941 */
942 bool valid_;
943
945 Size number_of_shift_sets_;
946
948 Size number_of_assigned_shifts_;
949
951 EntryInformation entry_information_;
952
954 MolecularSystem molecular_system_;
955
957 std::vector<NMRAtomDataSet> atom_data_sets_;
958
960 std::vector<SampleCondition> sample_conditions_;
961
963 std::vector<Sample> samples_;
964
966 std::vector<ShiftReferenceSet> shift_references_;
967
969 std::vector<NMRSpectrometer> nmr_spectrometers_;
970
972 vector<MonomericPolymer> monomeric_polymers_;
973
975 bool has_H_shifts_;
976 bool has_C_shifts_;
977 bool has_N_shifts_;
978
979 // a dummy saveframe
980 SaveFrame dummy_saveframe_;
981
982 // a dummy sample condition
983 SampleCondition dummy_sample_condition_;
984
985 // a dummy sample
986 Sample dummy_sample_;
987
988 // a dummy shift reference set
989 ShiftReferenceSet dummy_shift_reference_set_;
990
991 // a dummy nmr spectrometer
992 NMRSpectrometer dummy_NMR_spectrometer_;
993
994 // a dummy nmr spectrometer
995 MonomericPolymer dummy_monomeric_polymer_;
996
998 String special_characters_;
999 //_@}
1000 };
1001
1003} // Namespace BALL
1004
1005#endif // BALL_FORMAT_NMRSTARFILE_H
bool has(const String &key) const
This class provides methods for reading and assigning chemical shifts.
void addMonomericPolymer(MonomericPolymer mp)
NMRSpectrometer & getNMRSpectrometerByName(String name)
Get the spectrometer by its SaveFrame name.
bool hasSampleCondition(String name)
SampleCondition & getSampleConditionByName(String name)
MolecularSystem & getMolecularInformation()
ShiftReferenceSet & getShiftReferenceSet(Position i)
Get the i-th shift reference set.
SampleCondition & getSampleCondition(Position i)
Get the i-th SampleCondition.
const std::vector< NMRSpectrometer > & getNMRSpectrometers() const
Get the spectrometers.
Size getNumberOfNMRSpectrometers() const
Get the number of nmr spectrometers.
Size getNumberOfShiftsAssigned() const
Size getNumberOfMonomericPolymers() const
Get the number of monomeric polymers in the file.
const ShiftReferenceSet & getShiftReferenceSet(Position i) const
Get the i-th shift reference set.
const NMRStarFile::MonomericPolymer & getMonomericPolymer(const String &name) const
String getResidueSequence(Position i=0) const
String getNMRSpectrometerManufacturer(Position i) const
Get the spectrometer manufacturer.
const std::vector< SampleCondition > & getSampleConditions() const
Get the sample conditions.
bool hasCshifts() const
Check, whether this NMRFile provides carbon shifts.
Sample getSample(String label) const
static const float FLOAT_VALUE_NA
MolecularSystem::ChemicalUnit & getChemicalUnitByLabel(String const &label)
bool hasNshifts() const
Check, whether this NMRFile provides nitrogen shifts.
NMRStarFile::MonomericPolymer & getMonomericPolymer(Position i)
bool hasSampleCondition(String name) const
const SampleCondition & getSampleConditionByName(String name) const
const std::vector< NMRAtomDataSet > & getNMRData() const
const NMRSpectrometer & getNMRSpectrometer(Position i) const
Get the i-th spectrometer.
const MolecularSystem::ChemicalUnit & getChemicalUnitByLabel(String const &label) const
bool hasShiftReferenceSet(String name)
Check if there is a ShiftReferenceSet named name.
bool assignShifts(BALLToBMRBMapper &ball_to_bmrb_mapping)
bool hasMonomericPolymer(String name) const
Check if polymer name is already stored is a monomeric polymer.
Size getNumberOfAtoms() const
const NMRSpectrometer & getNMRSpectrometerByName(String name) const
Get the spectrometer by its SaveFrame name.
bool hasSample(String label) const
Return true if the file contains a sample named label, false otherwise.
bool isMonomericPolymer(String chemical_unit_label)
vector< MonomericPolymer > getMonomericPolymers() const
Get all Monomeric Polymers.
NMRStarFile(const String &file_name, File::OpenMode open_mode=std::ios::in)
bool assignShifts(AtomContainer &ac, const String &chemical_unit, const String &aligned_ball_sequence, const String &aligned_nmrstar_sequence)
std::vector< ShiftReferenceSet > & getShiftReferenceSets()
Get the shift reference sets.
static const Position POSITION_VALUE_NA
NMRStarFile::MonomericPolymer & getMonomericPolymer(const String &name)
std::vector< SampleCondition > & getSampleConditions()
Get the sample conditions.
std::vector< NMRSpectrometer > & getNMRSpectrometers()
Get the spectrometers.
Size getNumberOfSampleConditions() const
Get the number of sample conditions.
const SampleCondition & getSampleCondition(Position i) const
Get the i-th SampleCondition.
NMRSpectrometer & getNMRSpectrometer(Position i)
Get the i-th spectrometer.
static const int INT_VALUE_NA
Sample getSample(Position i) const
bool hasHshifts() const
Check, whether this NMRFile provides hydrogen shifts.
float getNMRSpectrometerFieldStrength(Position i) const
Get the spectrometer field strength.
Size getNumberOfShiftReferenceSets() const
Get the number of shift reference sets.
bool read(AtomContainer &ac)
ShiftReferenceSet & getShiftReferenceSetByName(String name)
Get a ShiftReferenceSet by its SaveFrame name.
const NMRStarFile::MonomericPolymer & getMonomericPolymer(Position i) const
std::vector< Sample > getSamples() const
Get the samples.
Size getNumberOfSamples() const
Get the number of samples.
const ShiftReferenceSet & getShiftReferenceSetByName(String name) const
Get a ShiftReferenceSet by its SaveFrame name.
~NMRStarFile()
Destructor.
const MolecularSystem & getMolecularInformation() const
const EntryInformation & getEntryInformation() const
const std::vector< ShiftReferenceSet > & getShiftReferenceSets() const
Get the shift reference sets.
StringHashMap< String > units
StringHashMap< float > errors
StringHashMap< float > values
vector< Component > components
std::vector< ShiftReferenceElement > elements
std::vector< NMRAtomData > atom_data
std::vector< String > samples
NMRAtomDataSet(NMRStarFile *parent)
StringHashMap< String > residues_by_index
vector< HomologDB > homolog_database_entries
ChemicalUnit const & getChemicalUnit(Position i) const
vector< ChemicalUnit > chemical_units
float system_molecular_weight
The systems molecular weigth in dalton.
vector< RelatedDB > related_database_entries
ChemicalUnit & getChemicalUnit(Position i)
void setChain(Chain const &chain)
Set the chain.
Peptides::NameConverter name_converter_
const Atom * getBALLAtom(const NMRAtomData &nmr_atom) const
std::pair< Position, Position > BMRBIndex
const Chain * getChain() const
Get the chain.
std::map< Atom const *, BMRBIndex > BALLToBMRBMapping
const NMRStarFile * getNMRStarFile() const
Get the NMRStar file.
BALLToBMRBMapper(Chain const &chain, const NMRStarFile &nmr_data, const String &chemical_unit)
BMRBToBALLMapping & getBMRBToBALLMapping()
Return the mapping
BALLToBMRBMapping & getBALLToBMRBMapping()
Return the mapping
bool isMapped(Atom const *atom) const
int getNumberOfGaps()
Return the number of mismatches in the current mapping.
const NMRAtomDataSet * getNMRAtomDataSet() const
std::map< const NMRAtomData *, Atom const * > BMRBToBALLMapping
int getNumberOfMismatches()
Return the number of mismatches in the current mapping.
bool isMapped(const NMRAtomData &nmr_atom) const
Test whether the given nmr atom data is mapped to a structure atom.
virtual ~BALLToBMRBMapper()
Destructor.
void setNMRStarFile(NMRStarFile const &nmrfile)
Set the NMRStar file.
const BALLToBMRBMapping & getBALLToBMRBMapping() const
Return the mapping
void setNMRAtomDataSet(NMRAtomDataSet const &nmr_atom_data_set)
Set the NMRAtomDataSet.
BALLToBMRBMapping ball_to_bmrb_map_
map BALL atoms to NMR atom data
const NMRAtomDataSet * nmr_atom_data_set_
bool setNMRAtomDataSetByName(String const &chemical_unit_name)
Set the NMRAtomDataSet by chemical unit name.
const BMRBToBALLMapping & getBMRBToBALLMapping() const
Return the mapping
BMRBToBALLMapping bmrb_to_ball_map_
map NMR atom data to BALL atoms
bool createMapping(const String &aligned_ball_sequence, const String &aligned_nmrstar_sequence)
This class provides conversion of atom names between naming schemata.
Definition peptides.h:152
std::ios::openmode OpenMode
Definition file.h:165
#define BALL_EXPORT