diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..e8d795a9 Binary files /dev/null and b/.DS_Store differ diff --git a/Project1-DNA/.DS_Store b/Project1-DNA/.DS_Store new file mode 100644 index 00000000..bb9e2cf3 Binary files /dev/null and b/Project1-DNA/.DS_Store differ diff --git a/Project1-DNA/Project1-DNA.xcodeproj/project.pbxproj b/Project1-DNA/Project1-DNA.xcodeproj/project.pbxproj new file mode 100644 index 00000000..317790ae --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/project.pbxproj @@ -0,0 +1,220 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 01E815BD16531E0E001FFDCF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 01E815BC16531E0E001FFDCF /* main.m */; }; + 01E815BF16531E0E001FFDCF /* Project1_DNA.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 01E815BE16531E0E001FFDCF /* Project1_DNA.1 */; }; + 01E815C716531ED7001FFDCF /* Cell.m in Sources */ = {isa = PBXBuildFile; fileRef = 01E815C616531ED7001FFDCF /* Cell.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 01E815B616531E0E001FFDCF /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 01E815BF16531E0E001FFDCF /* Project1_DNA.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 01E815B816531E0E001FFDCF /* Project1-DNA */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "Project1-DNA"; sourceTree = BUILT_PRODUCTS_DIR; }; + 01E815BC16531E0E001FFDCF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 01E815BE16531E0E001FFDCF /* Project1_DNA.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Project1_DNA.1; sourceTree = ""; }; + 01E815C516531ED7001FFDCF /* Cell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cell.h; sourceTree = ""; }; + 01E815C616531ED7001FFDCF /* Cell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Cell.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 01E815B516531E0E001FFDCF /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 01E815AD16531E0E001FFDCF = { + isa = PBXGroup; + children = ( + 01E815BB16531E0E001FFDCF /* Project1-DNA */, + 01E815B916531E0E001FFDCF /* Products */, + ); + sourceTree = ""; + }; + 01E815B916531E0E001FFDCF /* Products */ = { + isa = PBXGroup; + children = ( + 01E815B816531E0E001FFDCF /* Project1-DNA */, + ); + name = Products; + sourceTree = ""; + }; + 01E815BB16531E0E001FFDCF /* Project1-DNA */ = { + isa = PBXGroup; + children = ( + 01E815BC16531E0E001FFDCF /* main.m */, + 01E815C516531ED7001FFDCF /* Cell.h */, + 01E815C616531ED7001FFDCF /* Cell.m */, + 01E815BE16531E0E001FFDCF /* Project1_DNA.1 */, + ); + path = "Project1-DNA"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 01E815B716531E0E001FFDCF /* Project1-DNA */ = { + isa = PBXNativeTarget; + buildConfigurationList = 01E815C216531E0E001FFDCF /* Build configuration list for PBXNativeTarget "Project1-DNA" */; + buildPhases = ( + 01E815B416531E0E001FFDCF /* Sources */, + 01E815B516531E0E001FFDCF /* Frameworks */, + 01E815B616531E0E001FFDCF /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Project1-DNA"; + productName = "Project1-DNA"; + productReference = 01E815B816531E0E001FFDCF /* Project1-DNA */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 01E815AF16531E0E001FFDCF /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0440; + ORGANIZATIONNAME = "ic-it"; + }; + buildConfigurationList = 01E815B216531E0E001FFDCF /* Build configuration list for PBXProject "Project1-DNA" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 01E815AD16531E0E001FFDCF; + productRefGroup = 01E815B916531E0E001FFDCF /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 01E815B716531E0E001FFDCF /* Project1-DNA */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 01E815B416531E0E001FFDCF /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 01E815BD16531E0E001FFDCF /* main.m in Sources */, + 01E815C716531ED7001FFDCF /* Cell.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 01E815C016531E0E001FFDCF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 01E815C116531E0E001FFDCF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; + }; + name = Release; + }; + 01E815C316531E0E001FFDCF /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 01E815C416531E0E001FFDCF /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 01E815B216531E0E001FFDCF /* Build configuration list for PBXProject "Project1-DNA" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 01E815C016531E0E001FFDCF /* Debug */, + 01E815C116531E0E001FFDCF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 01E815C216531E0E001FFDCF /* Build configuration list for PBXNativeTarget "Project1-DNA" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 01E815C316531E0E001FFDCF /* Debug */, + 01E815C416531E0E001FFDCF /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 01E815AF16531E0E001FFDCF /* Project object */; +} diff --git a/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..884aa6ff --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/gameshock3.xcuserdatad/UserInterfaceState.xcuserstate b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/gameshock3.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..376061fb Binary files /dev/null and b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/gameshock3.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/ic-it.xcuserdatad/UserInterfaceState.xcuserstate b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/ic-it.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 00000000..1ffede76 Binary files /dev/null and b/Project1-DNA/Project1-DNA.xcodeproj/project.xcworkspace/xcuserdata/ic-it.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist new file mode 100644 index 00000000..cc25f9ea --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -0,0 +1,31 @@ + + + + + + + + + diff --git a/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/Project1-DNA.xcscheme b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/Project1-DNA.xcscheme new file mode 100644 index 00000000..f696be2e --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/Project1-DNA.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/xcschememanagement.plist b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..0f628a7b --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/gameshock3.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Project1-DNA.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 01E815B716531E0E001FFDCF + + primary + + + + + diff --git a/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/Project1-DNA.xcscheme b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/Project1-DNA.xcscheme new file mode 100644 index 00000000..f696be2e --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/Project1-DNA.xcscheme @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/xcschememanagement.plist b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000..0f628a7b --- /dev/null +++ b/Project1-DNA/Project1-DNA.xcodeproj/xcuserdata/ic-it.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,22 @@ + + + + + SchemeUserState + + Project1-DNA.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + 01E815B716531E0E001FFDCF + + primary + + + + + diff --git a/Project1-DNA/Project1-DNA/Cell.h b/Project1-DNA/Project1-DNA/Cell.h new file mode 100644 index 00000000..e8fd1999 --- /dev/null +++ b/Project1-DNA/Project1-DNA/Cell.h @@ -0,0 +1,35 @@ +// +// Cell.h +// Project1-DNA +// +// Created by ic-it on 11/14/12. +// Copyright (c) 2012 ic-it. All rights reserved. +// + +#import + +@interface Cell : NSObject{ + + NSMutableArray *DNA; + +} + +- (id) init; +- (int) hammingDistance:(Cell*) nbr; +- (id) getElement: (int) i; + + +@end + +/* + Создайте новое консольное приложение в XCode. + Создайте класс Cell, который наследуется от NSObject. + В классе создайте переменную DNA типа NSMutableArray – массив из 100 символов. Этот массив будет представлять ДНК. Вам нужно самостоятельно разобраться с созданием массива и выбрать класс или тип для использования для символов. + Создайте собственный метод init. Не забудьте в нем вызвать [super init] (см. Self и перегрузка Init). В этом методе задайте значение каждого из 100 символов в случайном порядке из множества A, T, G и С. Иными словами, каждая ячейка вашего массива должна быть одним из этих четырех символов. + Создайте метод hammingDistance, который возвращает int и принимает объект класса Cell. Этот метод должен сравнивать свой ДНК и ДНК переданного в качестве аргумента объекта и возвращать количество позиций где символы ДНК не совпадают. Например: + ATGGCATTTAGC + ATAGCTTTTCGC + На трех позициях ДНК не совпадают, значит hamming distance = 3. + Создайте категорию mutator класса Cell. В ней опишите метод mutate, который возвращает void и принимает int. + Создайте имплементацию (реализацию) метода mutate. Метод должен заменить X процентов символов в массиве DNA в случайном порядке; Х – значение переданной переменной типа int. Нужно заменить строго Х процентов, то есть заменять одну ячейку можно максимум один раз. + В main-функции создайте два объекта класса Cell, выведите на экран hamming distance между их ДНК, потом мутируйте каждый из объектов и выведите на экран новый hamming distance.*/ \ No newline at end of file diff --git a/Project1-DNA/Project1-DNA/Cell.m b/Project1-DNA/Project1-DNA/Cell.m new file mode 100644 index 00000000..5b7d260e --- /dev/null +++ b/Project1-DNA/Project1-DNA/Cell.m @@ -0,0 +1,40 @@ +// +// Cell.m +// Project1-DNA +// +// Created by ic-it on 11/14/12. +// Copyright (c) 2012 ic-it. All rights reserved. +// + +#import "Cell.h" + +@implementation Cell + +- (id) init{ + self = [super init]; + if (self){ + DNA = [[NSMutableArray alloc] initWithCapacity:100]; + NSArray *chrome = [NSArray arrayWithObjects:@"A",@"T",@"G",@"C",nil]; + srandom((unsigned)(mach_absolute_time()&0xFFFFFFFF)); + for (int i=0;i<100;i++) + [DNA insertObject:[chrome objectAtIndex:random()%4] atIndex:i ]; + NSLog(@"%@",DNA); + } + return self; +} + +- (int) hammingDistance:(Cell*) nbr{ + int hdCounter=0; + for (int i=0;i<100;i++){ + if ([self getElement:i]!=[nbr getElement:i]) + hdCounter++; + } + return hdCounter; + +} + +- (id) getElement: (int) i{ + return [DNA objectAtIndex:i]; +} +@end + diff --git a/Project1-DNA/Project1-DNA/Project1_DNA.1 b/Project1-DNA/Project1-DNA/Project1_DNA.1 new file mode 100644 index 00000000..4ff5129b --- /dev/null +++ b/Project1-DNA/Project1-DNA/Project1_DNA.1 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 11/14/12 \" DATE +.Dt Project1-DNA 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm Project1-DNA, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file diff --git a/Project1-DNA/Project1-DNA/main.m b/Project1-DNA/Project1-DNA/main.m new file mode 100644 index 00000000..6f5a1073 --- /dev/null +++ b/Project1-DNA/Project1-DNA/main.m @@ -0,0 +1,58 @@ +// +// main.c +// Project1-DNA +// +// Created by ic-it on 11/14/12. +// Copyright (c) 2012 ic-it. All rights reserved. +// + +#include +#include "Cell.h" + +@interface Cell (Mutation) +- (void) mutate: (int) x; +@end + +@implementation Cell (Mutation) +- (void) mutate: (int) x{ +/* NSMutableArray *pos = [[NSMutableArray alloc] initWithCapacity:x]; + bool overlap = YES; + NSNumber *tmp = [[NSNumber alloc] initWithInt:0]; + int tmp2; + for (int i=0;i